summaryrefslogtreecommitdiff
path: root/scripts/gen-as-const.awk
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
commit0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch)
tree2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /scripts/gen-as-const.awk
parent7d58530341304d403a6626d7f7a1913165fe2f32 (diff)
downloadglibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.gz
2.5-18.1
Diffstat (limited to 'scripts/gen-as-const.awk')
-rw-r--r--scripts/gen-as-const.awk28
1 files changed, 24 insertions, 4 deletions
diff --git a/scripts/gen-as-const.awk b/scripts/gen-as-const.awk
index a315066422..c529fa42c8 100644
--- a/scripts/gen-as-const.awk
+++ b/scripts/gen-as-const.awk
@@ -13,7 +13,17 @@ BEGIN { started = 0 }
/^#/ { print; next }
NF >= 1 && !started {
- print "void dummy(void) {";
+ if (test) {
+ print "\n#include <stdio.h>";
+ print "\nstatic int do_test (void)\n{\n int bad = 0, good = 0;\n";
+ print "#define TEST(name, source, expr) \\\n" \
+ " if (asconst_##name != (expr)) { ++bad;" \
+ " fprintf (stderr, \"%s: %s is %ld but %s is %ld\\n\"," \
+ " source, #name, (long int) asconst_##name, #expr, (long int) (expr));" \
+ " } else ++good;\n";
+ }
+ else
+ print "void dummy(void) {";
started = 1;
}
@@ -25,8 +35,18 @@ NF == 1 { sub(/^.*$/, "& &"); }
NF > 1 {
name = $1;
sub(/^[^ ]+[ ]+/, "");
- printf "asm (\"@@@name@@@%s@@@value@@@%%0@@@end@@@\" : : \"i\" (%s));\n",
- name, $0;
+ if (test)
+ print " TEST (" name ", \"" FILENAME ":" FNR "\", " $0 ")";
+ else
+ printf "asm (\"@@@name@@@%s@@@value@@@%%0@@@end@@@\" : : \"i\" (%s));\n",
+ name, $0;
}
-END { if (started) print "}" }
+END {
+ if (test) {
+ print " printf (\"%d errors in %d tests\\n\", bad, good + bad);"
+ print " return bad != 0 || good == 0;\n}\n";
+ print "#define TEST_FUNCTION do_test ()";
+ }
+ else if (started) print "}";
+}