From 15fdd8548168892dde3e9a66b27c7830aaa1095f Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 5 Oct 2021 04:38:55 +0100 Subject: [PATCH] Fix tests path. --- tests/CMakeLists.txt | 4 ++-- tests/adler32.cpp | 9 ++++++++- tests/crc16.cpp | 9 ++++++++- tests/crc16_ccitt.cpp | 11 +++++++++-- tests/crc32.cpp | 9 ++++++++- tests/crc64.cpp | 9 ++++++++- tests/fletcher16.cpp | 9 ++++++++- tests/fletcher32.cpp | 9 ++++++++- tests/spamsum.cpp | 9 ++++++++- 9 files changed, 67 insertions(+), 11 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c2b3f03..0036127 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,9 +6,9 @@ add_subdirectory(lib) include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/random - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/random) + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/) # 'Google_Tests_run' is the target name # 'test1.cpp tests2.cpp' are source files with tests -add_executable(tests_run adler32.cpp crc16.cpp crc32.cpp crc64.cpp fletcher16.cpp fletcher32.cpp spamsum.cpp) +add_executable(tests_run adler32.cpp crc16.cpp crc16_ccitt.cpp crc32.cpp crc64.cpp fletcher16.cpp fletcher32.cpp spamsum.cpp) target_link_libraries(tests_run gtest gtest_main "Aaru.Checksums.Native") \ No newline at end of file diff --git a/tests/adler32.cpp b/tests/adler32.cpp index 2362294..72342cd 100644 --- a/tests/adler32.cpp +++ b/tests/adler32.cpp @@ -2,6 +2,7 @@ // Created by claunia on 5/10/21. // +#include #include #include "../library.h" @@ -24,7 +25,13 @@ class adler32Fixture : public ::testing::Test protected: void SetUp() { - FILE* file = fopen("/home/claunia/random", "rb"); + char path[PATH_MAX]; + char filename[PATH_MAX]; + + getcwd(path, PATH_MAX); + snprintf(filename, PATH_MAX, "%s/data/random", path); + + FILE* file = fopen(filename, "rb"); buffer = (const uint8_t*)malloc(1048576); fread((void*)buffer, 1, 1048576, file); fclose(file); diff --git a/tests/crc16.cpp b/tests/crc16.cpp index 5b59a9b..1275adf 100644 --- a/tests/crc16.cpp +++ b/tests/crc16.cpp @@ -2,6 +2,7 @@ // Created by claunia on 5/10/21. // +#include #include #include "../library.h" @@ -24,7 +25,13 @@ class crc16Fixture : public ::testing::Test protected: void SetUp() { - FILE* file = fopen("/home/claunia/random", "rb"); + char path[PATH_MAX]; + char filename[PATH_MAX]; + + getcwd(path, PATH_MAX); + snprintf(filename, PATH_MAX, "%s/data/random", path); + + FILE* file = fopen(filename, "rb"); buffer = (const uint8_t*)malloc(1048576); fread((void*)buffer, 1, 1048576, file); fclose(file); diff --git a/tests/crc16_ccitt.cpp b/tests/crc16_ccitt.cpp index f526d71..dd0d032 100644 --- a/tests/crc16_ccitt.cpp +++ b/tests/crc16_ccitt.cpp @@ -2,10 +2,11 @@ // Created by claunia on 5/10/21. // +#include #include -#include "../crc16_ccitt.h" #include "../library.h" +#include "../crc16_ccitt.h" #include "gtest/gtest.h" #define EXPECTED_CRC16_CCITT 0x3640 @@ -24,7 +25,13 @@ class crc16_ccittFixture : public ::testing::Test protected: void SetUp() { - FILE* file = fopen("/home/claunia/random", "rb"); + char path[PATH_MAX]; + char filename[PATH_MAX]; + + getcwd(path, PATH_MAX); + snprintf(filename, PATH_MAX, "%s/data/random", path); + + FILE* file = fopen(filename, "rb"); buffer = (const uint8_t*)malloc(1048576); fread((void*)buffer, 1, 1048576, file); fclose(file); diff --git a/tests/crc32.cpp b/tests/crc32.cpp index ccb0c9b..13049e1 100644 --- a/tests/crc32.cpp +++ b/tests/crc32.cpp @@ -2,6 +2,7 @@ // Created by claunia on 5/10/21. // +#include #include #include "../library.h" @@ -24,7 +25,13 @@ class crc32Fixture : public ::testing::Test protected: void SetUp() { - FILE* file = fopen("/home/claunia/random", "rb"); + char path[PATH_MAX]; + char filename[PATH_MAX]; + + getcwd(path, PATH_MAX); + snprintf(filename, PATH_MAX, "%s/data/random", path); + + FILE* file = fopen(filename, "rb"); buffer = (const uint8_t*)malloc(1048576); fread((void*)buffer, 1, 1048576, file); fclose(file); diff --git a/tests/crc64.cpp b/tests/crc64.cpp index 16fb4d6..9c22c16 100644 --- a/tests/crc64.cpp +++ b/tests/crc64.cpp @@ -2,6 +2,7 @@ // Created by claunia on 5/10/21. // +#include #include #include "../library.h" @@ -24,7 +25,13 @@ class crc64Fixture : public ::testing::Test protected: void SetUp() { - FILE* file = fopen("/home/claunia/random", "rb"); + char path[PATH_MAX]; + char filename[PATH_MAX]; + + getcwd(path, PATH_MAX); + snprintf(filename, PATH_MAX, "%s/data/random", path); + + FILE* file = fopen(filename, "rb"); buffer = (const uint8_t*)malloc(1048576); fread((void*)buffer, 1, 1048576, file); fclose(file); diff --git a/tests/fletcher16.cpp b/tests/fletcher16.cpp index 6c604cd..42ba8e4 100644 --- a/tests/fletcher16.cpp +++ b/tests/fletcher16.cpp @@ -2,6 +2,7 @@ // Created by claunia on 5/10/21. // +#include #include #include "../library.h" @@ -24,7 +25,13 @@ class fletcher16Fixture : public ::testing::Test protected: void SetUp() { - FILE* file = fopen("/home/claunia/random", "rb"); + char path[PATH_MAX]; + char filename[PATH_MAX]; + + getcwd(path, PATH_MAX); + snprintf(filename, PATH_MAX, "%s/data/random", path); + + FILE* file = fopen(filename, "rb"); buffer = (const uint8_t*)malloc(1048576); fread((void*)buffer, 1, 1048576, file); fclose(file); diff --git a/tests/fletcher32.cpp b/tests/fletcher32.cpp index ff1ba69..e2daa18 100644 --- a/tests/fletcher32.cpp +++ b/tests/fletcher32.cpp @@ -2,6 +2,7 @@ // Created by claunia on 5/10/21. // +#include #include #include "../library.h" @@ -24,7 +25,13 @@ class fletcher32Fixture : public ::testing::Test protected: void SetUp() { - FILE* file = fopen("/home/claunia/random", "rb"); + char path[PATH_MAX]; + char filename[PATH_MAX]; + + getcwd(path, PATH_MAX); + snprintf(filename, PATH_MAX, "%s/data/random", path); + + FILE* file = fopen(filename, "rb"); buffer = (const uint8_t*)malloc(1048576); fread((void*)buffer, 1, 1048576, file); fclose(file); diff --git a/tests/spamsum.cpp b/tests/spamsum.cpp index f540e66..32774db 100644 --- a/tests/spamsum.cpp +++ b/tests/spamsum.cpp @@ -2,6 +2,7 @@ // Created by claunia on 5/10/21. // +#include #include #include "../library.h" @@ -24,7 +25,13 @@ class spamsumFixture : public ::testing::Test protected: void SetUp() { - FILE* file = fopen("/home/claunia/random", "rb"); + char path[PATH_MAX]; + char filename[PATH_MAX]; + + getcwd(path, PATH_MAX); + snprintf(filename, PATH_MAX, "%s/data/random", path); + + FILE* file = fopen(filename, "rb"); buffer = (const uint8_t*)malloc(1048576); fread((void*)buffer, 1, 1048576, file); fclose(file);