From e927a6064896e39de9800339d977107948ef70d5 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Wed, 26 Jun 2019 19:49:36 +0200 Subject: [PATCH] test: Enable argv test, run tests with arguments. * build-aux/check-mescc.sh (TESTS): Enable 54-argv.c (XFAIL_TESTS): Remove it. * build-aux/test-c.sh: Invoke test with options. * lib/tests/scaffold/54-argc.c: Update. --- build-aux/check-mescc.sh | 2 +- build-aux/test-c.sh | 3 +-- lib/tests/scaffold/54-argc.c | 2 +- lib/tests/scaffold/54-argv.c | 15 ++++++++++----- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/build-aux/check-mescc.sh b/build-aux/check-mescc.sh index 6dd1262d..578346cd 100755 --- a/build-aux/check-mescc.sh +++ b/build-aux/check-mescc.sh @@ -107,6 +107,7 @@ lib/tests/string/50-strcpy.c lib/tests/string/50-strncmp.c lib/tests/scaffold/51-pointer-sub.c lib/tests/scaffold/54-argc.c +lib/tests/scaffold/54-argv.c lib/tests/scaffold/55-char-array.c lib/tests/scaffold/60-math.c lib/tests/scaffold/61-array.c @@ -210,7 +211,6 @@ lib/tests/scaffold/a1-global-no-clobber.c " XFAIL_TESTS=" -lib/tests/scaffold/54-argv.c lib/tests/stdio/90-sprintf.c lib/tests/stdio/90-sprintf.c " diff --git a/build-aux/test-c.sh b/build-aux/test-c.sh index 5f7e1dff..03a88665 100755 --- a/build-aux/test-c.sh +++ b/build-aux/test-c.sh @@ -59,8 +59,7 @@ $CC -c $CPPFLAGS $CFLAGS -o "$o".o "$t" $CC $CFLAGS $LDFLAGS -L . -o "$o" $crt1 "$o".o $LIBS set +e -#timeout 2 "$o" -s --long file0 file1 > "$o".1 2> "$o".2 -timeout 2 "$o" > "$o".1 2> "$o".2 +timeout 2 "$o" -s --long file0 file1 > "$o".1 2> "$o".2 r=$? set -e if [ -f "$b".exit ]; then diff --git a/lib/tests/scaffold/54-argc.c b/lib/tests/scaffold/54-argc.c index baba655c..525204d9 100644 --- a/lib/tests/scaffold/54-argc.c +++ b/lib/tests/scaffold/54-argc.c @@ -29,7 +29,7 @@ main (int argc, char *argv[]) oputs ("argc="); oputs (itoa (argc)); oputs ("\n"); - if (argc != 1) + if (argc != 5) return 1; return 0; diff --git a/lib/tests/scaffold/54-argv.c b/lib/tests/scaffold/54-argv.c index 65da62de..350e4119 100644 --- a/lib/tests/scaffold/54-argv.c +++ b/lib/tests/scaffold/54-argv.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -27,20 +27,25 @@ int main (int argc, char *argv[]) { oputs ("\n"); - oputs ("t: argv[0] == \"lib/test/scaffold....\"\n"); + oputs ("t: argv[0] == \"lib/tests/scaffold....\"\n"); oputs ("argv0="); oputs (argv[0]); oputs ("\n"); - if (strncmp (argv[0], "lib/test/scaffold", 5)) + if (strcmp (argv[0], "lib/tests/scaffold/54-argv")) return 1; oputs ("t: *argv\"\n"); oputs (*argv); oputs ("\n"); - oputs ("t: if (argc > 1 && !strcmp (argv[1], \"--help\")\n"); - if (argc > 1 && !strcmp (argv[1], "--help")) + if (argc != 5) return 2; + if (strcmp (argv[1], "-s")) + return 3; + + if (strcmp (argv[2], "--long")) + return 4; + return 0; }