summaryrefslogtreecommitdiff
path: root/fuzz
diff options
context:
space:
mode:
authorTim Rühsen <tim.ruehsen@gmx.de>2018-06-19 12:02:13 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2018-06-20 12:06:41 +0000
commit953e343c4cebe9d728f385e89dddb8a05576e279 (patch)
tree9a333f2e86dc3996e173365f2d902f2a56a82d7d /fuzz
parentd1240a03839f3c1ddd65acea9496622615ee3183 (diff)
downloadgnutls-953e343c4cebe9d728f385e89dddb8a05576e279.tar.gz
Remove oss-fuzz copora from tarball
The size of the corpora is huge and not needed for normal builds. This patch also fixes test run issues on Windows.
Diffstat (limited to 'fuzz')
-rw-r--r--fuzz/Makefile.am4
-rw-r--r--fuzz/main.c45
2 files changed, 38 insertions, 11 deletions
diff --git a/fuzz/Makefile.am b/fuzz/Makefile.am
index 9093034aca..3483f0cc81 100644
--- a/fuzz/Makefile.am
+++ b/fuzz/Makefile.am
@@ -57,10 +57,12 @@ gnutls_set_trust_file_fuzzer_LDADD = $(LDADD) $(LIBDL)
#EXTRA_DIST = $(wildcard *.options) $(wildcard *.dict) \
# $(wildcard *.in) $(wildcard *.repro)
+# We don't include the fuzz corpora into the tarball.
+# Testing the corpora during dev cycles and in the CI is enough.
dist-hook:
find . -name '*.options' -exec cp -v '{}' $(distdir) ';'
find . -name '*.dict' -exec cp -v '{}' $(distdir) ';'
- find . -name '*.in' -exec cp -vr '{}' $(distdir) ';'
+# find . -name '*.in' -exec cp -vr '{}' $(distdir) ';'
find . -name '*.repro' -exec cp -vr '{}' $(distdir) ';'
TESTS = $(FUZZERS)
diff --git a/fuzz/main.c b/fuzz/main.c
index 5ef0b99e1c..cdeba17238 100644
--- a/fuzz/main.c
+++ b/fuzz/main.c
@@ -37,7 +37,13 @@
#include <dirent.h>
-static void test_all_from(const char *dirname)
+#ifdef _WIN32
+# define SLASH '\\'
+#else
+# define SLASH '/'
+#endif
+
+static int test_all_from(const char *dirname)
{
DIR *dirp;
struct dirent *dp;
@@ -76,27 +82,46 @@ static void test_all_from(const char *dirname)
close(fd);
}
closedir(dirp);
+ return 0;
}
+
+ return 1;
}
int main(int argc, char **argv)
{
- const char *target = strrchr(argv[0], '/');
- target = target ? target + 1 : argv[0];
+ const char *target;
+ size_t target_len;
- char corporadir[sizeof(SRCDIR) + 1 + strlen(target) + 8];
+ if ((target = strrchr(argv[0], SLASH)))
+ target = strrchr(target, '/');
+ else
+ target = strrchr(argv[0], '/');
+ target = target ? target + 1 : argv[0];
- if (strncmp(target, "lt-", 3) == 0) {
+ if (strncmp(target, "lt-", 3) == 0)
target += 3;
- }
- snprintf(corporadir, sizeof(corporadir), SRCDIR "/%s.in", target);
+ target_len = strlen(target);
+
+#ifdef _WIN32
+ target_len -= 4; // ignore .exe
+#endif
- test_all_from(corporadir);
+ {
+ int rc;
+ char corporadir[sizeof(SRCDIR) + 1 + target_len + 8];
+ snprintf(corporadir, sizeof(corporadir), SRCDIR "/%.*s.in", (int) target_len, target);
- snprintf(corporadir, sizeof(corporadir), SRCDIR "/%s.repro", target);
+ rc = test_all_from(corporadir);
+ if (rc)
+ fprintf(stderr, "Failed to find %s\n", corporadir);
- test_all_from(corporadir);
+ snprintf(corporadir, sizeof(corporadir), SRCDIR "/%.*s.repro", (int) target_len, target);
+
+ if (test_all_from(corporadir) && rc)
+ return 77;
+ }
return 0;
}