diff options
author | Paul Smith <psmith@gnu.org> | 2013-10-05 16:10:30 -0400 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2013-10-05 16:10:30 -0400 |
commit | 2fb91e19a02ff8a3e43145d582cfebaf3a60f1d9 (patch) | |
tree | 7bd7b902fd68f6df94c90d7544184067031a2502 /tests | |
parent | f96c114e22c26dbcd18b7c16590b5e0ef0c58fe9 (diff) | |
download | gunmake-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')
-rw-r--r-- | tests/ChangeLog | 6 | ||||
-rw-r--r-- | tests/scripts/features/loadapi | 30 |
2 files changed, 32 insertions, 4 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 75cf8dc..0ff5033 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2013-10-05 Paul Smith <psmith@gnu.org> + + * scripts/features/loadapi: Use new calling signatures. Verify + the NOEXPAND flag works. Test with all valid function name + characters. + 2013-09-29 Paul Smith <psmith@gnu.org> * scripts/variables/SHELL: Solaris /bin/sh can't handle options in 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. |