Add a model for gzdopen

Summary: Add model for gzdopen

Reviewed By: ddino

Differential Revision: D3223727

fb-gh-sync-id: a4d55fb
fbshipit-source-id: a4d55fb
master
Jeremy Dubreil 9 years ago committed by Facebook Github Bot 7
parent 46fc0bb1dc
commit 049c353f52

@ -494,6 +494,9 @@ FILE* fdopen(int fildes, const char* mode) {
return fopen("foo", mode); return fopen("foo", mode);
} }
// modeled using fdopen
FILE* gzdopen(int fildes, const char* mode) { return fdopen(fildes, mode); }
// return nonteterministically 0 or -1 // return nonteterministically 0 or -1
// requires stream to be allocated // requires stream to be allocated
int fseek(FILE* stream, long int offset, int whence) { int fseek(FILE* stream, long int offset, int whence) {

@ -39,6 +39,22 @@ void fileClosed() {
} }
} }
FILE* handler;
void fdopen_example() {
int fd = open("hi.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (fd != -1) {
handler = fdopen(fd, "w");
}
}
void gzdopen_example() {
int fd = open("hi.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (fd != -1) {
handler = gzdopen(fd, "w");
}
}
void socketNotClosed() { void socketNotClosed() {
int fd = socket(AF_LOCAL, SOCK_RAW, 0); int fd = socket(AF_LOCAL, SOCK_RAW, 0);
if (fd != -1) { if (fd != -1) {

@ -10,7 +10,7 @@
package endtoend.c; package endtoend.c;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static utils.matchers.ResultContainsTheseErrors.contains; import static utils.matchers.ResultContainsExactly.containsExactly;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -41,11 +41,10 @@ public class ResourceLeakTest {
"fileNotClosed", "fileNotClosed",
"socketNotClosed" "socketNotClosed"
}; };
assertThat( assertThat(
"Results should contain " + RESOURCE_LEAK, "Results should contain " + RESOURCE_LEAK,
inferResults, inferResults,
contains( containsExactly(
RESOURCE_LEAK, RESOURCE_LEAK,
SOURCE_FILE, SOURCE_FILE,
functions functions

Loading…
Cancel
Save