summaryrefslogtreecommitdiff
path: root/tests/scripts
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-10-05 16:10:30 -0400
committerPaul Smith <psmith@gnu.org>2013-10-05 16:10:30 -0400
commit2fb91e19a02ff8a3e43145d582cfebaf3a60f1d9 (patch)
tree7bd7b902fd68f6df94c90d7544184067031a2502 /tests/scripts
parentf96c114e22c26dbcd18b7c16590b5e0ef0c58fe9 (diff)
downloadgunmake-2fb91e19a02ff8a3e43145d582cfebaf3a60f1d9.tar.gz
Sanitize the registered function interface.
Expand the characters which are legal in a function name, and check the name for validity. Create a type for the function pointer. Convert the last argument from a boolean to flags, to allow for expansion.
Diffstat (limited to 'tests/scripts')
-rw-r--r--tests/scripts/features/loadapi30
1 files changed, 26 insertions, 4 deletions
diff --git a/tests/scripts/features/loadapi b/tests/scripts/features/loadapi
index 4976ce3..6d3b03f 100644
--- a/tests/scripts/features/loadapi
+++ b/tests/scripts/features/loadapi
@@ -36,7 +36,15 @@ test_expand (const char *val)
}
static char *
-func_test (const char *funcname, int argc, char **argv)
+test_noexpand (const char *val)
+{
+ char *str = gmk_alloc (strlen (val));
+ strcpy (str, val);
+ return str;
+}
+
+static char *
+func_test (const char *funcname, unsigned int argc, char **argv)
{
char *mem;
@@ -46,7 +54,10 @@ func_test (const char *funcname, int argc, char **argv)
if (strcmp (funcname, "test-eval") == 0)
return test_eval (argv[0]);
- mem = gmk_alloc (strlen ("unknown") + 1);
+ if (strcmp (funcname, "test-noexpand") == 0)
+ return test_noexpand (argv[0]);
+
+ mem = gmk_alloc (sizeof ("unknown"));
strcpy (mem, "unknown");
return mem;
}
@@ -54,8 +65,10 @@ func_test (const char *funcname, int argc, char **argv)
int
testapi_gmk_setup ()
{
- gmk_add_function ("test-expand", func_test, 1, 1, 1);
- gmk_add_function ("test-eval", func_test, 1, 1, 1);
+ gmk_add_function ("test-expand", func_test, 1, 1, GMK_FUNC_DEFAULT);
+ gmk_add_function ("test-noexpand", func_test, 1, 1, GMK_FUNC_NOEXPAND);
+ gmk_add_function ("test-eval", func_test, 1, 1, GMK_FUNC_DEFAULT);
+ gmk_add_function ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.", func_test, 0, 0, 0);
return 1;
}
EOF
@@ -84,6 +97,15 @@ all:;@echo '$(VAR)'
!,
'', "hi there\n");
+# TEST 2
+# Check the no-expand capability
+run_make_test(q!
+load testapi.so
+TEST = hi
+all:;@echo '$(test-noexpand $(TEST))'
+!,
+ '', "\$(TEST)\n");
+
unlink(qw(testapi.c testapi.so)) unless $keep;
# This tells the test driver that the perl test script executed properly.