[clang] Fixing the tests for the models of getc.

master
Dulma Rodriguez 10 years ago
parent 3ce393f511
commit 34b911c935

@ -1,57 +1,43 @@
#include <stdio.h>
#include <stdlib.h>
void crashgetc() {
void crash_getc() {
FILE *f;
int i;
f=fopen("this_file_doesnt_exists", "r");
i =getc(f);
printf("i =%i\n", i);
f = fopen("this_file_doesnt_exists", "r");
i = getc(f);
printf("i =%i\n", i);
fclose(f);
}
void nocrashgetc() {
void nocrash_getc() {
FILE *f;
int i;
f=fopen("this_file_doesnt_exists", "r");
f = fopen("this_file_doesnt_exists", "r");
if (f) {
i =getc(f);
i = getc(f);
printf("i =%i\n", i);
fclose(f);
}
}
void crashfgetc() {
void crash_fgetc() {
FILE *f;
int i;
f=fopen("this_file_doesnt_exists", "r");
i =fgetc(f);
f = fopen("this_file_doesnt_exists", "r");
i = fgetc(f);
printf("i =%i\n", i);
fclose(f);
}
void nocrashfgetc() {
void nocrash_fgetc() {
FILE *f;
int i;
f=fopen("this_file_doesnt_exists", "r");
f = fopen("this_file_doesnt_exists", "r");
if (f) {
i =fgetc(f);
i = fgetc(f);
printf("i =%i\n", i);
fclose(f);
fclose(f);
}
}

@ -6,8 +6,7 @@
package endtoend.c;
import static org.hamcrest.MatcherAssert.assertThat;
import static utils.matchers.ResultContainsErrorInMethod.contains;
import static utils.matchers.ResultContainsExactly.containsExactly;
import org.junit.BeforeClass;
import org.junit.Test;
@ -20,7 +19,7 @@ import utils.InferResults;
public class NullDereferenceTest2 {
public static final String SOURCE_FILE =
"null_dereference/get.c";
"null_dereference/getc.c";
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
@ -34,31 +33,21 @@ public class NullDereferenceTest2 {
SOURCE_FILE);
}
/*
@Test
public void nullDereferenceTest2() throws InterruptedException, IOException, InferException {
assertThat(
"Results should contain null pointer dereference error",
inferResults,
contains(
NULL_DEREFERENCE,
SOURCE_FILE,
"crashgetc"
)
);
}
@Test
public void nullDereferenceTest2_fgetc() throws InterruptedException, IOException, InferException {
public void nullDereferenceTest() throws InterruptedException, IOException, InferException {
String[] procedures = {
"crash_getc",
"crash_fgetc",
};
System.out.println(inferResults.toString());
assertThat(
"Results should contain null pointer dereference error",
inferResults,
contains(
containsExactly(
NULL_DEREFERENCE,
SOURCE_FILE,
"crashfgetc"
procedures
)
);
}
*/
}

@ -107,6 +107,7 @@ public class InferResults {
for (InferError e : errors) {
s = s + "\n" + e.toString();
}
if (s.length() == 0) return "No results.";
return s;
}

Loading…
Cancel
Save