From 013e9da407a3b583db93f827f054cd2fd6127739 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Fri, 11 May 2012 09:31:24 -0400 Subject: Fix issue when running make distcheck When running 'make distcheck', all files in the $srcdir are set to read-only, to ensure that the build does not modify the source. However, this broke our ability to test file permissions. We will now copy the file to the builddir and do the tests there, where we have control. --- Makefile.am | 1 + configure.ac | 3 ++- ini/ini.d/foo.conf | 12 ------------ ini/ini.d/foo.conf.in | 12 ++++++++++++ ini/ini_parse_ut.c | 16 +++++----------- 5 files changed, 20 insertions(+), 24 deletions(-) delete mode 100644 ini/ini.d/foo.conf create mode 100644 ini/ini.d/foo.conf.in diff --git a/Makefile.am b/Makefile.am index 4b74b28..167bc1f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -289,6 +289,7 @@ endif clean-local-ini_config: rm -f ./*.out rm -f test.ini + rm -f ./foo.conf #From ini_parse_ut ############################################################################## # Additional rules diff --git a/configure.ac b/configure.ac index 2e22e8a..eae028f 100644 --- a/configure.ac +++ b/configure.ac @@ -77,5 +77,6 @@ AC_CONFIG_FILES([Makefile contrib/ding-libs.spec refarray/ref_array.cfg.doxy refarray/ref_array.pc basicobjects/basicobjects.cfg.doxy basicobjects/basicobjects.pc - ini/ini_config.cfg.doxy ini/ini_config.pc]) + ini/ini_config.cfg.doxy ini/ini_config.pc + ini/ini.d/foo.conf]) AC_OUTPUT diff --git a/ini/ini.d/foo.conf b/ini/ini.d/foo.conf deleted file mode 100644 index 44d56a1..0000000 --- a/ini/ini.d/foo.conf +++ /dev/null @@ -1,12 +0,0 @@ -#Hoho section -[hoho] -#Hoho value -val= hoho -#End of hoho -#Start of section -[foo] -#First value -bar = first value -#Second value -bar = second value -#End of section diff --git a/ini/ini.d/foo.conf.in b/ini/ini.d/foo.conf.in new file mode 100644 index 0000000..44d56a1 --- /dev/null +++ b/ini/ini.d/foo.conf.in @@ -0,0 +1,12 @@ +#Hoho section +[hoho] +#Hoho value +val= hoho +#End of hoho +#Start of section +[foo] +#First value +bar = first value +#Second value +bar = second value +#End of section diff --git a/ini/ini_parse_ut.c b/ini/ini_parse_ut.c index 75a1145..6cab9d4 100644 --- a/ini/ini_parse_ut.c +++ b/ini/ini_parse_ut.c @@ -42,6 +42,8 @@ char *confdir = NULL; if (verbose) foo; \ } while(0) +#define FOO_CONF "./ini/ini.d/foo.conf" + typedef int (*test_fn)(void); int test_one_file(const char *in_filename, @@ -327,10 +329,8 @@ int merge_values_test(void) const char *resname = "./merge.conf.out"; const char *checkname = "./expect.conf.out"; char command[PATH_MAX * 3]; - char *srcdir; - srcdir = getenv("srcdir"); - sprintf(filename, "%s/ini/ini.d/foo.conf", (srcdir == NULL) ? "." : srcdir); + memcpy(filename, FOO_CONF, sizeof(FOO_CONF)); error = simplebuffer_alloc(&sbobj); if (error) { @@ -639,11 +639,8 @@ int startup_test(void) struct ini_cfgobj *ini_config = NULL; char **error_list = NULL; char filename[PATH_MAX]; - char *srcdir; - srcdir = getenv("srcdir"); - sprintf(filename, "%s/ini/ini.d/foo.conf", - (srcdir == NULL) ? "." : srcdir); + memcpy(filename, FOO_CONF, sizeof(FOO_CONF)); INIOUT(printf("<==== Startup test ====>\n")); @@ -746,15 +743,12 @@ int reload_test(void) char infile[PATH_MAX]; char outfile[PATH_MAX]; const char *command = "cp"; - char *srcdir; char *builddir; int changed = 0; INIOUT(printf("<==== Reload test ====>\n")); - srcdir = getenv("srcdir"); - sprintf(infile, "%s/ini/ini.d/foo.conf", - (srcdir == NULL) ? "." : srcdir); + memcpy(infile, FOO_CONF, sizeof(FOO_CONF)); builddir = getenv("builddir"); sprintf(outfile, "%s/foo.conf", (builddir == NULL) ? "." : builddir); -- cgit