pgbackrest.git / summary / log / commit / refs
commit f9bbafbf3fbd67fc289cf849900799b4718dace1
Author: David Steele <david@pgmasters.net>
Date: Wed Jul 20 23:02:14 2022 +0000
C test harness improvements.
Add harness depends when present.
Include libyaml in all test builds.
Fix mode on paths before trying to remove and set test path with mode 770 to match the Perl test harness.
With these changes all unit tests run except those that specify the define (e.g. common/assert-off), binReq (e.g. command/archive-get), or containerReq (e.g. protocol/protocol) keywords.
Builds and code generation need to be done in advance. The following commands are required for setup:
meson setup -Dwerror=true -Dfatal-errors=true -Dbuildtype=debug build pgbackrest
ninja -C build test/src/test-pgbackrest
build/src/build-code help pgbackrest
build/src/build-code postgres pgbackrest
Now tests can be run, e.g.:
build/test/src/test-pgbackrest --module=postgres/interface
test/src/command/test/build.c | 14 +++++++++++++-
test/src/command/test/test.c | 7 ++++++-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/test/src/command/test/build.c b/test/src/command/test/build.c
index 3d5238b72..ebdeaa9b9 100644
--- a/test/src/command/test/build.c
+++ b/test/src/command/test/build.c
@@ -332,10 +332,21 @@ testBldUnit(TestBuild *const this)
strCatFmt(mesonBuild, " '%s/src/%s.c',\n", strZ(pathRepo), strZ(depend));
}
- // Add harnesses to meson build if no includes are in module or coverage includes
+ // Add harnesses
for (unsigned int harnessIdx = 0; harnessIdx < strLstSize(harnessList); harnessIdx++)
{
const TestDefHarness *const harness = lstGet(module->harnessList, harnessIdx);
+
+ // Add harness depends
+ const String *const harnessDependPath = strNewFmt(
+ "%s/test/src/common/%s", strZ(pathRepo), strZ(bldEnum("harness", harness->name)));
+ StorageIterator *const storageItr = storageNewItrP(
+ testBldStorageRepo(this), harnessDependPath, .expression = STRDEF("\\.c$"), .sortOrder = sortOrderAsc);
+
+ while (storageItrMore(storageItr))
+ strCatFmt(mesonBuild, " '%s/%s',\n", strZ(harnessDependPath), strZ(storageItrNext(storageItr).name));
+
+ // Add harness if no includes are in module or coverage includes
unsigned int includeIdx = 0;
for (; includeIdx < strLstSize(harness->includeList); includeIdx++)
@@ -368,6 +379,7 @@ testBldUnit(TestBuild *const this)
" lib_lz4,\n"
" lib_pq,\n"
" lib_xml,\n"
+ " lib_yaml,\n"
" lib_z,\n"
" lib_zstd,\n"
" ],\n"
diff --git a/test/src/command/test/test.c b/test/src/command/test/test.c
index b90676b83..b4b45fc1e 100644
--- a/test/src/command/test/test.c
+++ b/test/src/command/test/test.c
@@ -40,8 +40,13 @@ cmdTest(
// Remove and recreate the test path
const Storage *const storageTestId = storagePosixNewP(
strNewFmt("%s/test-%u", strZ(testBldPathTest(testBld)), testBldVmId(testBld)), .write = true);
+ const char *const permReset = zNewFmt("chmod -R 777 %s", strZ(storagePathP(storageTestId, NULL)));
+
+ if (system(permReset) != 0)
+ THROW_FMT(ExecuteError, "unable to execute: %s", permReset);
+
storagePathRemoveP(storageTestId, NULL, .recurse = true);
- storagePathCreateP(storageTestId, NULL);
+ storagePathCreateP(storageTestId, NULL, .mode = 0770);
// Meson setup
const String *const pathUnit = strNewFmt("%s/unit-%u", strZ(testBldPathTest(testBld)), testBldVmId(testBld));
[parent: c625f05a13e0]