From b99c2674b4aa26fde87dcac0c719ca562153449b Mon Sep 17 00:00:00 2001 From: Samuel Kayode <samuel.kayode@savoirfairelinux.com> Date: Wed, 7 Aug 2024 10:37:06 -0400 Subject: [PATCH] tests: fix account accumulation on Linux systems On non-dockerized Linux systems, the accounts generated during tests are only cleaned up occassionally. The test suite design implements consistent account cleanup post test. Accumulation of these accounts interfere with subsequent test runs, rendering the test suite ineffective. The main test scripts incorrectly utilize a Jami Windows environment variable for Linux systems. In adherence with the Jami client design, this patch utilizes the correct environment variable for Linux systems. Windows formatted paths were also modified to allow recogntion in Linux enironments GitLab: #1801 Change-Id: I633dbd168af1e6d20ccee53d1109cd179bd1a187 --- tests/qml/main.cpp | 16 +++++++++++++--- tests/unittests/main_unittest.cpp | 27 +++++++++++++++++++++------ 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/tests/qml/main.cpp b/tests/qml/main.cpp index 2fbecebe4..a08833481 100644 --- a/tests/qml/main.cpp +++ b/tests/qml/main.cpp @@ -44,6 +44,16 @@ #include <windows.h> #endif +#ifdef Q_OS_WIN +#define DATA_DIR "JAMI_DATA_HOME" +#define CONFIG_DIR "JAMI_CONFIG_HOME" +#define CACHE_DIR "JAMI_CACHE_HOME" +#else +#define DATA_DIR "XDG_DATA_HOME" +#define CONFIG_DIR "XDG_CONFIG_HOME" +#define CACHE_DIR "XDG_CACHE_HOME" +#endif + #include <atomic> #include <thread> @@ -178,9 +188,9 @@ main(int argc, char** argv) QDir(jamiConfigDir).removeRecursively(); QDir(jamiCacheDir).removeRecursively(); - bool envSet = qputenv("JAMI_DATA_HOME", jamiDataDir.toLocal8Bit()); - envSet &= qputenv("JAMI_CONFIG_HOME", jamiConfigDir.toLocal8Bit()); - envSet &= qputenv("JAMI_CACHE_HOME", jamiCacheDir.toLocal8Bit()); + bool envSet = qputenv(DATA_DIR, jamiDataDir.toLocal8Bit()); + envSet &= qputenv(CONFIG_DIR, jamiConfigDir.toLocal8Bit()); + envSet &= qputenv(CACHE_DIR, jamiCacheDir.toLocal8Bit()); if (!envSet) return 1; diff --git a/tests/unittests/main_unittest.cpp b/tests/unittests/main_unittest.cpp index 425f0a797..381ed39d7 100644 --- a/tests/unittests/main_unittest.cpp +++ b/tests/unittests/main_unittest.cpp @@ -22,6 +22,16 @@ #include <QApplication> #include <QStandardPaths> +#ifdef Q_OS_WIN +#define DATA_DIR "JAMI_DATA_HOME" +#define CONFIG_DIR "JAMI_CONFIG_HOME" +#define CACHE_DIR "JAMI_CACHE_HOME" +#else +#define DATA_DIR "XDG_DATA_HOME" +#define CONFIG_DIR "XDG_CONFIG_HOME" +#define CACHE_DIR "XDG_CACHE_HOME" +#endif + TestEnvironment globalEnv; int @@ -29,13 +39,18 @@ main(int argc, char* argv[]) { QDir tempDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation)); - auto jamiDataDir = tempDir.absolutePath() + "\\jami_test\\jami"; - auto jamiConfigDir = tempDir.absolutePath() + "\\jami_test\\.config"; - auto jamiCacheDir = tempDir.absolutePath() + "\\jami_test\\.cache"; + auto jamiDataDir = tempDir.absolutePath() + "/jami_test/jami"; + auto jamiConfigDir = tempDir.absolutePath() + "/jami_test/.config"; + auto jamiCacheDir = tempDir.absolutePath() + "/jami_test/.cache"; + + // Clean up the temp directories. + QDir(jamiDataDir).removeRecursively(); + QDir(jamiConfigDir).removeRecursively(); + QDir(jamiCacheDir).removeRecursively(); - bool envSet = qputenv("JAMI_DATA_HOME", jamiDataDir.toLocal8Bit()); - envSet &= qputenv("JAMI_CONFIG_HOME", jamiConfigDir.toLocal8Bit()); - envSet &= qputenv("JAMI_CACHE_HOME", jamiCacheDir.toLocal8Bit()); + bool envSet = qputenv(DATA_DIR, jamiDataDir.toLocal8Bit()); + envSet &= qputenv(CONFIG_DIR, jamiConfigDir.toLocal8Bit()); + envSet &= qputenv(CACHE_DIR, jamiCacheDir.toLocal8Bit()); if (!envSet) return 1; -- GitLab