fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/36614?usp=email )


Change subject: tests: do not copy *.cfg files to the build directory
......................................................................

tests: do not copy *.cfg files to the build directory

When running 'make check' in-tree ($builddir == $srcdir), those
*.cfg files end up in tests/ and show up as git-add candidates.
Instead of copying them, just let the test binaries know where
to find those files via the cmdline parameters.

Change-Id: I74e428f0548418fdecada3d25049d6e110e790fe
---
M tests/Makefile.am
M tests/msgfile/msgfile_test.c
M tests/testsuite.at
M tests/vty/vty_test.c
4 files changed, 32 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/14/36614/1

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8b1731d..45490f2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -550,8 +550,7 @@
        gea/gea_test \
                >$(srcdir)/gea/gea_test.ok
 if ENABLE_MSGFILE
-       cp $(srcdir)/msgfile/msgconfig.cfg .
-       msgfile/msgfile_test \
+       msgfile/msgfile_test $(srcdir)/msgfile/msgconfig.cfg \
                >$(srcdir)/msgfile/msgfile_test.ok
 endif
        sms/sms_test \
@@ -606,8 +605,7 @@
        strrb/strrb_test \
                >$(srcdir)/strrb/strrb_test.ok
 if ENABLE_VTY
-       cp $(srcdir)/vty/*.cfg .
-       vty/vty_test \
+       vty/vty_test $(srcdir)/vty \
                >$(srcdir)/vty/vty_test.ok \
                2>$(srcdir)/vty/vty_test.err
 endif
diff --git a/tests/msgfile/msgfile_test.c b/tests/msgfile/msgfile_test.c
index 3fe173d..ec58816 100644
--- a/tests/msgfile/msgfile_test.c
+++ b/tests/msgfile/msgfile_test.c
@@ -17,6 +17,7 @@

 #include <osmocom/core/msgfile.h>
 #include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>

 #include <stdio.h>

@@ -39,8 +40,8 @@
 {
        struct osmo_config_list *entries;

-       /* todo use msgfile_test.c.in and replace the path */
-       entries = osmo_config_list_parse(NULL, "msgconfig.cfg");
+       OSMO_ASSERT(argc > 1);
+       entries = osmo_config_list_parse(NULL, argv[1]);
        dump_entries(entries);
        talloc_free(entries);
 
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 9ff64ac..9f17ba3 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -84,9 +84,8 @@
 if ENABLE_MSGFILE
 AT_SETUP([msgfile])
 AT_KEYWORDS([msgfile])
-cp $abs_srcdir/msgfile/msgconfig.cfg .
 cat $abs_srcdir/msgfile/msgfile_test.ok > expout
-AT_CHECK([$abs_top_builddir/tests/msgfile/msgfile_test], [0], [expout])
+AT_CHECK([$abs_top_builddir/tests/msgfile/msgfile_test 
$abs_srcdir/msgfile/msgconfig.cfg], [0], [expout])
 AT_CLEANUP
 endif

@@ -243,8 +242,7 @@
 AT_KEYWORDS([vty])
 cat $abs_srcdir/vty/vty_test.ok > expout
 cat $abs_srcdir/vty/vty_test.err > experr
-cp $abs_srcdir/vty/*.cfg .
-AT_CHECK([$abs_top_builddir/tests/vty/vty_test], [0], [expout], [experr])
+AT_CHECK([$abs_top_builddir/tests/vty/vty_test $abs_srcdir/vty], [0], 
[expout], [experr])
 AT_CLEANUP

 AT_SETUP([gprs-bssgp])
diff --git a/tests/vty/vty_test.c b/tests/vty/vty_test.c
index 01e323e..a3f8489 100644
--- a/tests/vty/vty_test.c
+++ b/tests/vty/vty_test.c
@@ -39,6 +39,7 @@
 #include <osmocom/vty/stats.h>

 static enum event last_vty_connection_event = -1;
+static const char *cfg_path = NULL;
 void *ctx = NULL;

 static void test_cmd_string_from_valstr(void)
@@ -292,9 +293,12 @@

 void test_exit_by_indent(const char *fname, int expect_rc)
 {
+       char fpath[PATH_MAX];
        int rc;
+
        printf("reading file %s, expecting rc=%d\n", fname, expect_rc);
-       rc = vty_read_config_file(fname, NULL);
+       snprintf(&fpath[0], sizeof(fpath), "%s/%s", cfg_path, fname);
+       rc = vty_read_config_file(fpath, NULL);
        printf("got rc=%d\n", rc);
        OSMO_ASSERT(rc == expect_rc);
 }
@@ -618,6 +622,12 @@
        };
        void *stats_ctx;

+       if (argc < 2) {
+               fprintf(stderr, "Usage: %s CFG_PATH\n", argv[0]);
+               return 1;
+       }
+       cfg_path = argv[1];
+
        ctx = talloc_named_const(NULL, 0, "stats test context");
        stats_ctx = talloc_named_const(ctx, 1, "stats test context");


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/36614?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I74e428f0548418fdecada3d25049d6e110e790fe
Gerrit-Change-Number: 36614
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>
Gerrit-MessageType: newchange

Reply via email to