git » libfiu » commit 841c13e

tests/generated: Use #if instead of #ifdef

author Alberto Bertogli
2014-05-25 12:40:52 UTC
committer Alberto Bertogli
2014-05-25 23:44:44 UTC
parent 3edecb69d7a7f9fda67e13ddb4024062c4c314f0

tests/generated: Use #if instead of #ifdef

This patch makes the generated tests use #if instead of #ifdef, as it is more
generic and can allow for more complex expressions that will be needed in
future tests.

It also updates the existing tests to make use of it.

tests/generated/generate-test +4 -4
tests/generated/tests/mmap.conf +1 -1
tests/generated/tests/pread64.conf +1 -1

diff --git a/tests/generated/generate-test b/tests/generated/generate-test
index 8d5dae8..fec4585 100755
--- a/tests/generated/generate-test
+++ b/tests/generated/generate-test
@@ -110,8 +110,8 @@ def generate(options, outfile):
 	else:
 		outfile.write("\n\n")
 
-	if options['ifdef']:
-		outfile.write("#ifdef %s\n" % options['ifdef'])
+	if options['if']:
+		outfile.write("#if %s\n" % options['if'])
 
 	if 'errno_on_fail' in options:
 		options['errno_cond'] = \
@@ -126,7 +126,7 @@ def generate(options, outfile):
 	outfile.write(Template(TEST_FAILURE_TMPL).substitute(options))
 	outfile.write(Template(TEST_MAIN_TMPL).substitute(options))
 
-	if options['ifdef']:
+	if options['if']:
 		outfile.write("#else\n")
 		outfile.write(Template(TEST_SKIPPED_TMPL).substitute(options))
 		outfile.write("#endif\n")
@@ -148,7 +148,7 @@ def main():
 		'include': (),
 		'prep': '',
 
-		'ifdef': '',
+		'if': '',
 
 		# These are C conditions that are always true.
 		'success_cond': '1',
diff --git a/tests/generated/tests/mmap.conf b/tests/generated/tests/mmap.conf
index 68af0ca..6f58885 100644
--- a/tests/generated/tests/mmap.conf
+++ b/tests/generated/tests/mmap.conf
@@ -2,7 +2,7 @@
 [mmap]
 fp: posix/mm/mmap
 include: sys/mman.h unistd.h
-ifdef: _POSIX_MAPPED_FILES
+if: defined _POSIX_MAPPED_FILES
 prep: void *p;
 call: p = mmap(NULL, 4092, PROT_READ | PROT_WRITE,
 		MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
diff --git a/tests/generated/tests/pread64.conf b/tests/generated/tests/pread64.conf
index 11c4b85..4716eb8 100644
--- a/tests/generated/tests/pread64.conf
+++ b/tests/generated/tests/pread64.conf
@@ -1,6 +1,6 @@
 
 [pread64]
-ifdef: __GLIBC__
+if: defined __GLIBC__
 fp: posix/io/rw/pread
 include: unistd.h sys/types.h sys/stat.h fcntl.h
 prep: unsigned char buf[1024]; ssize_t r; int fd = open("/dev/zero", O_RDONLY);