changeset 661:6ba753927d3f

tests: replace test-file.c with test.c The previous commit duplicated test-file.c's functionality within test.c. As an added bonus, this change adds support for expected-panic-strings to file based test cases. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sun, 10 Feb 2019 21:45:35 -0500
parents eb3d260023b8
children e5d8203935d2
files tests/test-file.c tests/test_cbor_pack.c tests/test_nvl_pack.c tests/test_qstring.c tests/test_sexpr_parser.c
diffstat 5 files changed, 8 insertions(+), 76 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-file.c	Sun Feb 10 21:44:20 2019 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2016-2017 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <jeffpc/version.h>
-#include <jeffpc/error.h>
-
-static void test(const char *fname);
-
-/*
- * Do not make this static or the compiler may complain about an unused
- * static function.
- */
-void NORETURN fail(const char *fmt, ...)
-{
-	va_list ap;
-
-	fprintf(stderr, "TEST FAILED: ");
-
-	va_start(ap, fmt);
-	vfprintf(stderr, fmt, ap);
-	va_end(ap);
-
-	fprintf(stderr, "\n");
-
-	exit(1);
-}
-
-int main(int argc, char **argv)
-{
-	int i;
-
-	fprintf(stderr, "libjeffpc.so version %s\n", jeffpc_version);
-	fprintf(stderr, "Running tests (%s)\n", argv[0]);
-
-	for (i = 1; i < argc; i++) {
-		fprintf(stderr, "Checking %s...\n", argv[i]);
-
-		test(argv[i]);
-	}
-
-	fprintf(stderr, "Tests passed.\n");
-
-	return 0;
-}
--- a/tests/test_cbor_pack.c	Sun Feb 10 21:44:20 2019 -0500
+++ b/tests/test_cbor_pack.c	Sun Feb 10 21:45:35 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2017-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,7 @@
 #include <jeffpc/io.h>
 #include <jeffpc/mem.h>
 
-#include "test-file.c"
+#include "test.c"
 
 static inline void dumpbuf(struct buffer *buf)
 {
--- a/tests/test_nvl_pack.c	Sun Feb 10 21:44:20 2019 -0500
+++ b/tests/test_nvl_pack.c	Sun Feb 10 21:45:35 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2017-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,7 @@
 #include <jeffpc/sexpr.h>
 #include <jeffpc/io.h>
 
-#include "test-file.c"
+#include "test.c"
 
 static inline struct nvlist *alloc(void)
 {
--- a/tests/test_qstring.c	Sun Feb 10 21:44:20 2019 -0500
+++ b/tests/test_qstring.c	Sun Feb 10 21:45:35 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2014-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -25,7 +25,7 @@
 #include <jeffpc/qstring.h>
 #include <jeffpc/io.h>
 
-#include "test-file.c"
+#include "test.c"
 
 static int onefile(char *ibuf, size_t len)
 {
--- a/tests/test_sexpr_parser.c	Sun Feb 10 21:44:20 2019 -0500
+++ b/tests/test_sexpr_parser.c	Sun Feb 10 21:45:35 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2017 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2015-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -27,7 +27,7 @@
 #include <jeffpc/val.h>
 #include <jeffpc/io.h>
 
-#include "test-file.c"
+#include "test.c"
 
 static void trim(char *ptr)
 {