diff --git a/.github/workflows/run-standard-tests.yml b/.github/workflows/run-standard-tests.yml index 9545b5975..3a92bf85d 100644 --- a/.github/workflows/run-standard-tests.yml +++ b/.github/workflows/run-standard-tests.yml @@ -48,24 +48,32 @@ jobs: uses: ./.github/actions/build-khiops with: preset-name: ${{ env.PRESET_NAME }} - - name: Cache binaries - id: cache-binaries-unix + - name: Cache binaries (windows) + id: cache-binaries-windows + if: ${{ runner.os == 'Windows' }} uses: actions/cache@v3 with: # We add binaries path one by one to avoid *.pdb and other msvc stuffs that generate a cache of 200Mo for windows path: | - ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL - ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL_Coclustering - ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/KNITransfer ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL.exe ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL_Coclustering.exe ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/KNITransfer.exe ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/KhiopsNativeInterface.dll - ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/lib/libKhiopsNativeInterface.* ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/lib/KhiopsNativeInterface.lib key: ${{ github.run_id }}-${{ matrix.build-setup.os }}-${{ env.PRESET_NAME }} fail-on-cache-miss: false + - name: Cache binaries (macOS, Linux) + id: cache-binaries-unix + if: ${{ runner.os != 'Windows' }} + uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/* + ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/lib/libKhiopsNativeInterface.* + key: ${{ github.run_id }}-${{ matrix.build-setup.os }}-${{ env.PRESET_NAME + }} + fail-on-cache-miss: false run-standard-tests: needs: build-full-project strategy: @@ -83,23 +91,36 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v3 - - name: Restore cached binaries - id: restore-binaries + - name: Restore cached binaries (windows) + if: ${{ runner.os == 'Windows' }} + id: restore-binaries-windows uses: actions/cache/restore@v3 with: path: | - ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL - ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL_Coclustering - ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/KNITransfer ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL.exe ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL_Coclustering.exe ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/KNITransfer.exe ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/KhiopsNativeInterface.dll - ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/lib/libKhiopsNativeInterface.* ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/lib/KhiopsNativeInterface.lib key: ${{ github.run_id }}-${{ matrix.build-setup.os }}-${{ env.PRESET_NAME }} fail-on-cache-miss: true + - name: Restore cached binaries (macOS, Linux) + if: ${{ runner.os != 'Windows' }} + id: restore-binaries + uses: actions/cache/restore@v3 + with: + path: | + ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/* + ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/lib/libKhiopsNativeInterface.* + key: ${{ github.run_id }}-${{ matrix.build-setup.os }}-${{ env.PRESET_NAME + }} + fail-on-cache-miss: true + - name: Rename mpi binaries + if: ${{ runner.os == 'Linux' }} + shell: bash + run: | + mv ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL_openmpi ${{ github.workspace }}/build/${{ env.PRESET_NAME }}/bin/MODL - name: Setup Python uses: actions/setup-python@v4 with: @@ -134,8 +155,6 @@ jobs: # - In release run all Standard tests shell: bash run: | - export OMPI_MCA_orte_execute_quiet=true - export OMPI_MCA_rmaps_base_oversubscribe=true if [[ "${{ matrix.build-setup.os }}" == 'windows-2022' ]]; then export EXT=".exe" fi @@ -159,6 +178,7 @@ jobs: shell: bash if: success() || failure() run: | + mkdir results if [[ "${{ matrix.config }}" == "release" ]] ; then python $APPLY_PY test/LearningTest/TestKhiops/Standard errors | tee -a results/errors.txt if [[ "${{ matrix.running-mode }}" != "parallel" ]] ; then diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index 91fc32131..0e5981df1 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -50,33 +50,39 @@ jobs: build/${{ matrix.build-setup.cmake-preset }}/bin/norm_test \ --gtest_output="xml:reports/report-norm.xml" - name: Run Unit Tests for the Parallel Module - if: success() || failure() + if: always() run: | build/${{ matrix.build-setup.cmake-preset }}/bin/parallel_test \ --gtest_output="xml:reports/report-parallel.xml" - name: Run Unit Tests for the Parallel MPI Module in serial - if: success() || failure() + if: always() run: | build/${{ matrix.build-setup.cmake-preset }}/bin/parallel_mpi_test \ --gtest_output="xml:reports/report-parallel-mpi-serial.xml" - - name: Run Unit Tests for the Parallel MPI Module in parallel - if: success() || failure() + - name: Run Unit Tests for the Parallel MPI Module in parallel (Linux) + if: ${{ always() && runner.os == 'Linux' }} run: | - mpiexec -n 4 build/${{ matrix.build-setup.cmake-preset }}/bin/parallel_mpi_test \ + mpirun --oversubscribe --use-hwthread-cpus -n 4 build/${{ matrix.build-setup.cmake-preset }}/bin/parallel_mpi_test \ --gtest_output="xml:reports/report-parallel-mpi-parallel.xml" + - name: Run Unit Tests for the Parallel MPI Module in parallel (Windows and + macOS) + if: ${{ always() && runner.os != 'Linux' }} + run: | + mpiexec -n 4 build/${{ matrix.build-setup.cmake-preset }}/bin/parallel_mpi_test \ + --gtest_output="xml:reports/report-parallel-mpi-parallel.xml" - name: Run Unit Tests for the Learning Module - if: success() || failure() + if: always() run: | build/${{ matrix.build-setup.cmake-preset }}/bin/learning_test \ --gtest_output="xml:reports/report-learning.xml" - name: Run Unit Tests for the KNI Module - if: success() || failure() + if: always() run: | build/${{ matrix.build-setup.cmake-preset }}/bin/KNITest \ --gtest_output="xml:reports/report-kni.xml" - name: Create Unit Test Reports Dashboards uses: phoenix-actions/test-reporting@v12 - if: success() || failure() + if: always() with: name: Unit Tests Reports (${{ matrix.build-setup.os }}) reporter: jest-junit diff --git a/CMakeLists.txt b/CMakeLists.txt index c6ed496ec..1ec3fb711 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -376,12 +376,12 @@ if(TESTING) enable_testing() # Add testing targets - add_subdirectory(test/Norm) - add_subdirectory(test/Parallel) - add_subdirectory(test/Parallel-mpi) - add_subdirectory(test/Learning) - add_subdirectory(test/KNITest) - add_subdirectory(test/Utils) + add_subdirectory(test/UnitTests/Norm) + add_subdirectory(test/UnitTests/Parallel) + add_subdirectory(test/UnitTests/Parallel-mpi) + add_subdirectory(test/UnitTests/Learning) + add_subdirectory(test/UnitTests/KNITest) + add_subdirectory(test/UnitTests/Utils) endif(TESTING) # Exclude googletest from the installation diff --git a/test/LearningTestTool/py/kht_test.py b/test/LearningTestTool/py/kht_test.py index 416efe6ea..3b41bf00e 100644 --- a/test/LearningTestTool/py/kht_test.py +++ b/test/LearningTestTool/py/kht_test.py @@ -17,7 +17,7 @@ mpi_exe_name = "mpiexec.exe" # mpiexec sous Linux else: - mpi_exe_name = "mpiexec" + mpi_exe_name = "mpirun" def build_tool_exe_path(tool_binaries_dir, tool_name): @@ -274,10 +274,19 @@ def evaluate_tool_on_test_dir( khiops_params.append(mpi_exe_name) # Option -l, specifique a mpich, valide au moins pour Windows: # "Label standard out and standard error (stdout and stderr) with the rank of the process" - khiops_params.append("-l") + if platform.system() == "Windows": + khiops_params.append("-l") if platform.system() == "Darwin": khiops_params.append("-host") khiops_params.append("localhost") + # Options specifiques a Open MPI + if platform.system() == "Linux": + # permet de lancer plus de processus qu'il n'y a de coeurs + khiops_params.append("--oversubscribe") + # permet de lancer en tant que root + khiops_params.append("--allow-run-as-root ") + # Ajoute le rang du processus dans les traces + khiops_params.append("--tag-output") khiops_params.append("-n") khiops_params.append(str(tool_process_number)) khiops_params.append(tool_exe_path) @@ -389,7 +398,8 @@ def evaluate_tool_on_test_dir( lines = utils.filter_copyright_lines( lines ) # Supression eventuelle des lignes de copyright - lines = utils.filter_empty_lines(lines) # Suopression des lignes vides + # Suopression des lignes vides + lines = utils.filter_empty_lines(lines) # Pour les test KNI, le stdout contient une ligne avec le nombre de records if is_kni: diff --git a/test/UnitTests/KNITest/KNITest.cpp b/test/UnitTests/KNITest/KNITest.cpp index 81dea0892..b4d9e8ede 100644 --- a/test/UnitTests/KNITest/KNITest.cpp +++ b/test/UnitTests/KNITest/KNITest.cpp @@ -9,7 +9,7 @@ #include "KNITest.h" #include "TestServices.h" -#include "../../src/Learning/KNITransfer/KNIRecodeFile.cpp" +#include "../../../src/Learning/KNITransfer/KNIRecodeFile.cpp" #define MAXITER 1000 #define MAXBUFFERSIZE 1000 @@ -199,7 +199,7 @@ void TestIris() sTestPath = FileService::GetPathName(__FILE__); sDictionaryPath = FileService::BuildFilePathName(sTestPath, "ModelingIris.kdic"); - sDataPath = FileService::BuildFilePathName(sTestPath, "../LearningTest/datasets/Iris/Iris.txt"); + sDataPath = FileService::BuildFilePathName(sTestPath, "../../LearningTest/datasets/Iris/Iris.txt"); sOutputPath = sTestPath + "results" + FileService::GetFileSeparator() + "R_Iris.txt"; sRefFilePath = sTestPath + "results.ref" + FileService::GetFileSeparator() + "R_Iris.txt"; @@ -232,8 +232,8 @@ void TestAdult() boolean bOk; sTestPath = FileService::GetPathName(__FILE__); - sDictionaryPath = FileService::BuildFilePathName(sTestPath, "../LearningTest/datasets/Adult/Adult.kdic"); - sDataPath = FileService::BuildFilePathName(sTestPath, "../LearningTest/datasets/Adult/Adult.txt"); + sDictionaryPath = FileService::BuildFilePathName(sTestPath, "../../LearningTest/datasets/Adult/Adult.kdic"); + sDataPath = FileService::BuildFilePathName(sTestPath, "../../LearningTest/datasets/Adult/Adult.txt"); sOutputPath = sTestPath + "results" + FileService::GetFileSeparator() + "R_Adult.txt"; // Test de deploiement @@ -246,20 +246,20 @@ void TestAdult() // Saut du header FileService::OpenInputBinaryFile(sDataPath, fRef); - ch = getc(fRef); + ch = (char)getc(fRef); while (ch != '\n' and ch != EOF) { - ch = getc(fRef); + ch = (char)getc(fRef); } // Copie du fichier tel quel sRefFilePath = sTestPath + "results" + FileService::GetFileSeparator() + "ref_Adult.txt"; FileService::OpenOutputBinaryFile(sRefFilePath, fWithoutHeader); - ch = getc(fRef); + ch = (char)getc(fRef); while (ch != EOF) { putc(ch, fWithoutHeader); - ch = getc(fRef); + ch = (char)getc(fRef); } FileService::CloseInputBinaryFile(sDataPath, fRef); FileService::CloseOutputBinaryFile(sRefFilePath, fWithoutHeader); diff --git a/test/UnitTests/KNITest/KNITest.h b/test/UnitTests/KNITest/KNITest.h index 2ea0542be..bb1f2f5f2 100644 --- a/test/UnitTests/KNITest/KNITest.h +++ b/test/UnitTests/KNITest/KNITest.h @@ -10,4 +10,4 @@ #include #include "KhiopsNativeInterface.h" -#include "../../src/Learning/KNITransfer/KNIRecodeFile.h" +#include "../../../src/Learning/KNITransfer/KNIRecodeFile.h" diff --git a/test/UnitTests/KNITest/results.ref/KNI_Adult.txt b/test/UnitTests/KNITest/results.ref/KNI_Adult.txt index 36df7eebd..af8c67af8 100644 --- a/test/UnitTests/KNITest/results.ref/KNI_Adult.txt +++ b/test/UnitTests/KNITest/results.ref/KNI_Adult.txt @@ -1,5 +1,5 @@ -Recode records of @ROOT_DIR@/test/KNITest/../LearningTest/datasets/Adult/Adult.txt to @ROOT_DIR@/test/KNITest/results/R_Adult.txt +Recode records of @ROOT_DIR@/UnitTests/KNITest/../../LearningTest/datasets/Adult/Adult.txt to @ROOT_DIR@/UnitTests/KNITest/results/R_Adult.txt Recoded record number: 48842 -End test Adult \ No newline at end of file +End test Adult diff --git a/test/UnitTests/KNITest/results.ref/KNI_Iris.txt b/test/UnitTests/KNITest/results.ref/KNI_Iris.txt index cef7691f9..162c89f8a 100644 --- a/test/UnitTests/KNITest/results.ref/KNI_Iris.txt +++ b/test/UnitTests/KNITest/results.ref/KNI_Iris.txt @@ -1,7 +1,7 @@ Begin test KNI SYS KNI version: 110 SYS KNI full version: 10.1.5 -Open stream @ROOT_DIR@/test/KNITest/ModelingIris.kdic SNB_Iris: 1 +Open stream @ROOT_DIR@/UnitTests/KNITest/ModelingIris.kdic SNB_Iris: 1 Recode stream record Iris-setosa Iris-setosa 0.9960418693 0.001979090503 0.001979040221: 0 Recode stream record Iris-virginica Iris-virginica 0.00198971666 0.03512915094 0.9628811324: 0 Recode invalid stream record : -14 @@ -14,12 +14,12 @@ Recode stream record with negative output size : -15 Wrong parameter tests Open stream with NULL dictionary file NULL SNB_Iris: -2 Open stream with missing dictionary file WrongFile SNB_Iris: -3 -Open stream with invalid dictionary file @ROOT_DIR@/test/KNITest/../LearningTest/datasets/Iris/Iris.txt SNB_Iris: -4 -Open stream with NULL dictionary @ROOT_DIR@/test/KNITest/ModelingIris.kdic NULL: -5 -Open stream with missing dictionary @ROOT_DIR@/test/KNITest/ModelingIris.kdic WrongDic: -6 -Open stream with NULL header line @ROOT_DIR@/test/KNITest/ModelingIris.kdic SNB_Iris: -8 -Open stream with bad header line @ROOT_DIR@/test/KNITest/ModelingIris.kdic SNB_Iris: -23 -Open stream with eol separator @ROOT_DIR@/test/KNITest/ModelingIris.kdic SNB_Iris: -9 +Open stream with invalid dictionary file @ROOT_DIR@/UnitTests/KNITest/../../LearningTest/datasets/Iris/Iris.txt SNB_Iris: -4 +Open stream with NULL dictionary @ROOT_DIR@/UnitTests/KNITest/ModelingIris.kdic NULL: -5 +Open stream with missing dictionary @ROOT_DIR@/UnitTests/KNITest/ModelingIris.kdic WrongDic: -6 +Open stream with NULL header line @ROOT_DIR@/UnitTests/KNITest/ModelingIris.kdic SNB_Iris: -8 +Open stream with bad header line @ROOT_DIR@/UnitTests/KNITest/ModelingIris.kdic SNB_Iris: -23 +Open stream with eol separator @ROOT_DIR@/UnitTests/KNITest/ModelingIris.kdic SNB_Iris: -9 Recode with wrong stream : -10 Close wrong stream (-1): -10 Close wrong stream (0): -10 @@ -30,7 +30,7 @@ SYS => stream index 317 => Error -22 Muliple close stream -Recode records of @ROOT_DIR@/test/KNITest/../LearningTest/datasets/Iris/Iris.txt to @ROOT_DIR@/test/KNITest/results/R_Iris.txt +Recode records of @ROOT_DIR@/UnitTests/KNITest/../../LearningTest/datasets/Iris/Iris.txt to @ROOT_DIR@/UnitTests/KNITest/results/R_Iris.txt Recoded record number: 150 -End test KNI \ No newline at end of file +End test KNI diff --git a/test/UnitTests/Utils/ParallelTest.h b/test/UnitTests/Utils/ParallelTest.h index d2990014a..03c0bd04a 100644 --- a/test/UnitTests/Utils/ParallelTest.h +++ b/test/UnitTests/Utils/ParallelTest.h @@ -4,8 +4,8 @@ #include "gtest/gtest.h" -// Fixture a utiliser pour realiser les test en sequentiel, en parallele et en simule. -// Les tests qui utilisent cette fixture vont etre lancer en sequentiel puis en simule (sauf si il y a plus d'un +// Fixture a utiliser pour realiser les tests en sequentiel, en parallele et en simule. +// Les tests qui utilisent cette fixture vont etre lance en sequentiel puis en simule (sauf si il y a plus d'un // processus, auquel cas le test est skippe) Pour lancer les test il faut definir les tests avec parametres // (Value-parameterized tests) et les instancier INSTANTIATE_TEST_SUITE_P(nom_du_test, nom_de_la_classe , // testing::Values(RunType::MPI, RunType::SIMULATED)); diff --git a/test/UnitTests/Utils/TestServices.cpp b/test/UnitTests/Utils/TestServices.cpp index be254107f..89c5b36d8 100644 --- a/test/UnitTests/Utils/TestServices.cpp +++ b/test/UnitTests/Utils/TestServices.cpp @@ -66,13 +66,17 @@ boolean FileCompareForTest(const ALString& sFileNameReference, const ALString& s boolean bOk1; boolean bOk2; boolean bSame = true; - const char sys[] = "SYS"; + const char sSys[] = "SYS"; int nLineIndex; - const int sizeMax = 512; - char lineRef[sizeMax]; - char lineTest[sizeMax]; + const int nMaxSize = 5000; // Permet de stocker un path tres long + char lineRef[nMaxSize]; + char lineTest[nMaxSize]; + ALString sLineTest; + ALString sLineRef; + int nLineLength; const ALString sRootDir = GetRootDir(); const ALString sTmpDir = FileService::GetTmpDir(); + int nPos; // Initialisations bOk1 = false; @@ -94,50 +98,70 @@ boolean FileCompareForTest(const ALString& sFileNameReference, const ALString& s } // Ouverture des fichiers - bOk1 = FileService::OpenInputBinaryFile(sFileNameReference, fileRef); - if (bOk1) + fileRef = p_fopen(sFileNameReference, "r"); + if (fileRef == NULL) { - bOk2 = FileService::OpenInputBinaryFile(sFileNameTest, fileTest); - if (not bOk2) - { - fclose(fileRef); - return false; - } + cout << "Unable to open ref file" << endl; + return false; + } + + fileTest = p_fopen(sFileNameTest, "r"); + if (not fileTest) + { + fclose(fileRef); + return false; } // Comparaison ligne par ligne - if (bOk1 and bOk2) + nLineIndex = 0; + while (fgets(lineRef, sizeof(lineRef), fileRef) != NULL) { - nLineIndex = 0; - while (fgets(lineRef, sizeof(lineRef), fileRef) != NULL) + nLineIndex++; + + // Si il manque des lignes, il y a une erreur + if (fgets(lineTest, sizeof(lineTest), fileTest) == NULL) { - nLineIndex++; - if (fgets(lineTest, sizeof(lineTest), fileTest) == NULL) - { - bSame = false; - break; - } - - // Remplacement du repêrtoire de travail par @ROOT_DIR@ - // du repertoire temporaire par @TMP_DIR@ - // et du separateur windows par le separateur unix - SearchAndReplace(lineTest, sRootDir, "@ROOT_DIR@"); - SearchAndReplace(lineTest, sTmpDir, "@TMP_DIR@"); - SearchAndReplace(lineTest, "\\", "/"); - - // Si les 2 lignes sont differentes et qu'elles ne commencent pas toutes - // les 2 par SYS, les fichiers sont differents - if (not(memcmp(lineRef, sys, strlen(sys) - 1) == 0 and - memcmp(lineTest, sys, strlen(sys) - 1) == 0) and - (strcmp(lineRef, lineTest) != 0)) - { - bSame = false; - break; - } + bSame = false; + break; } + // Nettoyage des fin de ligne avant de passer aux ALString + nLineLength = (int)strlen(lineTest); + if (nLineLength > 0 and lineTest[nLineLength - 1] == '\n') + lineTest[nLineLength - 1] = '\0'; + nLineLength = (int)strlen(lineRef); + if (nLineLength > 0 and lineRef[nLineLength - 1] == '\n') + lineRef[nLineLength - 1] = '\0'; + sLineTest = ALString(lineTest); + sLineRef = ALString(lineRef); + + // Remplacement du repertoire de travail par @ROOT_DIR@ + // du repertoire temporaire par @TMP_DIR@ + SearchAndReplace(sLineTest, sRootDir, "@ROOT_DIR@"); + SearchAndReplace(sLineTest, sTmpDir, "@TMP_DIR@"); + + // On cherche la premiere occurence de 'SYS' dans la ligne de ref + nPos = sLineRef.Find(sSys); + + // Est-ce que les lignes sont identiques ? + bSame = strncmp(sLineRef, sLineTest, nPos) == 0; + + // Si les 2 lignes sont differentes (jusqu'au token SYS) if (not bSame) - cout << endl << "error at line " << nLineIndex << endl << "=> " << lineTest << endl; + { + // On remplace le separateur windows par le separateur unix pour etre + // tolerant dans les chemins et on compare a nouveau les lignes + SearchAndReplace(sLineTest, "\\", "/"); + bSame = strncmp(sLineRef, sLineTest, nPos) == 0; + if (not bSame) + break; + } + } + if (not bSame) + { + cout << endl << "error at line " << nLineIndex << endl; + cout << "Ref: " << sLineRef << endl; + cout << "Test: " << sLineTest << endl; } // Fermeture des fichiers @@ -184,7 +208,9 @@ boolean TestAndCompareResults(const char* sTestPath, const char* test_suite, con ALString sFileName; FILE* stream; int fdInit; - int fd; + + // On passe en mode batch pour avoir des parametres par defaut, sans interaction utilisateur + SetAcquireBatchMode(true); // Nommmage du ficher de sortie d'apres test suit et test name de googleTest sFileName = sTmp + test_suite + "_" + test_name + ".txt"; @@ -219,6 +245,8 @@ boolean TestAndCompareResults(const char* sTestPath, const char* test_suite, con bOk = FileCompareForTest(sTmp + sTestPath + "results.ref" + FileService::GetFileSeparator() + sFileName, sTestFileName); + // Restitution du mode standard + SetAcquireBatchMode(false); EXPECT_TRUE(bOk); return true; } diff --git a/test/UnitTests/Utils/TestServices.h b/test/UnitTests/Utils/TestServices.h index eef84847b..d5f04e3ad 100644 --- a/test/UnitTests/Utils/TestServices.h +++ b/test/UnitTests/Utils/TestServices.h @@ -31,8 +31,15 @@ // Cet appel a la macro va lancer la methode Integer::Test() en redirigeant la // sortie standard vers le fichier ./results/Integer_full.txt et ensuite // comparer ce fichier avec le fichier de reference -// ./results.ref/Integer_full.txt. Ce fichier doit avoir ete cree par ailleurs -// lors de la mise au point de la methode Integer::Test(). +// ./results.ref/Integer_full.txt. +// Lors de la mise au point, le fichier Integer_full.txt est cree dans le repertoire +// results et le test echoue car il n'y a pas de fichier de reference. Il suffit +// de copier ce fichier dans le repertoire results.ref pour que le test reussisse. +// Pour que le test soit valide sur differentes machines, il faut si necessaire remplacer +// dans le fichier de reference les chemins propres à l'environnement par des tags, a savoir : +// - le repertoire temporaire par @TMP_DIR@ +// - le repertoire qui contient le projet des tests unitaires par @ROOT_DIR@ +// Cela concerne essentiellement les tests impliquant des fichiers temporaires. // // Le test est reussi lorsque les 2 fichiers sont identiques (a l'exception des // lignes qui commencent par "SYS" qui peuvent etre differentes) @@ -57,7 +64,8 @@ } // Comparaison de 2 fichiers ligne par ligne -// Les fichiers peuvent differer pour les lignes qui commencent par 'SYS' +// Si deux lignes contiennent le token 'SYS', elles sont comparees uniquement jusqu'a ce token: tout ce qui est derriere +// est ignore. Il y a egalement une tolerance pour le caractere separateur dans les chemins '\' qui est remplace par '/' // Renvoie true si les 2 fichiers existent et sont identiques boolean FileCompareForTest(const ALString& sFileNameReference, const ALString& sFileNameTest);