aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/external/c-testsuite/scripts/add-single-exec
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-13 19:21:04 +0100
committerlemon <lsof@mailbox.org>2025-12-13 19:21:04 +0100
commite51ac7ec7d3e32e1771c9f824da3dc7e4dcd2bc5 (patch)
treea0b7a0c29247374b96fdbfb29bc365d15e9e36a5 /test/external/c-testsuite/scripts/add-single-exec
parent6c7cdc537b7b341f9ca25a3e8b61de46c99840e7 (diff)
add c-testsuite
Diffstat (limited to 'test/external/c-testsuite/scripts/add-single-exec')
-rwxr-xr-xtest/external/c-testsuite/scripts/add-single-exec78
1 files changed, 78 insertions, 0 deletions
diff --git a/test/external/c-testsuite/scripts/add-single-exec b/test/external/c-testsuite/scripts/add-single-exec
new file mode 100755
index 0000000..3685432
--- /dev/null
+++ b/test/external/c-testsuite/scripts/add-single-exec
@@ -0,0 +1,78 @@
+#! /usr/bin/env bash
+
+set -e
+set -u
+set -x
+
+if ! test -f README.md
+then
+ echo "run from the base directory." >&2
+ exit 1
+fi
+
+in=$1
+
+if ! test -f $in
+then
+ echo "$in does not exist" >&2
+ exit 1
+fi
+
+chosenfile=""
+foundname="n"
+for n in $(seq 10000)
+do
+ paddedn=$(printf "%05d" "$n")
+ chosenfile="./tests/single-exec/$paddedn.c"
+
+ if test -f "$chosenfile"
+ then
+ continue
+ fi
+
+ foundname="y"
+ break
+done
+
+if test "$foundname" = "n"
+then
+ echo "no numbers left." >&2
+ exit 1
+fi
+
+
+cat $in > "$chosenfile"
+added="y"
+tagfile="$chosenfile.tags"
+
+echo "inferring tags..." 1>&2
+
+echo "portable" > $tagfile
+
+# Check for cstd
+if gcc -pedantic --std=c89 -c -o /tmp/ctestsuite-infer.o $in
+then
+ echo "c89" >> $tagfile
+elif gcc -pedantic --std=c99 -c -o /tmp/ctestsuite-infer.o $in
+then
+ echo "c99" >> $tagfile
+elif gcc -pedantic --std=c11 -c -o /tmp/ctestsuite-infer.o $in
+then
+ echo "c11" >> $tagfile
+else
+ echo "unable to guess c std"
+fi
+
+if grep -q -e "#include" "$in"
+then
+ # Since these are single file tests, the only
+ # thing we could include would be libc headers.
+ echo "needs-libc" >> $tagfile
+fi
+
+if grep -q -e "#include" -e "#define" -e "#if" -e "#ifdef" "$in"
+then
+ echo "needs-cpp" >> $tagfile
+fi
+
+echo "$chosenfile" \ No newline at end of file