diff --git a/Makefile b/Makefile index c9aa01b65..82c89e87a 100644 --- a/Makefile +++ b/Makefile @@ -748,8 +748,8 @@ tests/test-c.o: tests/test-c.c llama.h tests/test-backend-ops: tests/test-backend-ops.cpp ggml.o $(OBJS) $(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS) -tests/test-model-load-cancel: tests/test-model-load-cancel.cpp ggml.o llama.o tests/get_model.cpp $(COMMON_DEPS) $(OBJS) +tests/test-model-load-cancel: tests/test-model-load-cancel.cpp ggml.o llama.o tests/get-model.cpp $(COMMON_DEPS) $(OBJS) $(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS) -tests/test-autorelease: tests/test-autorelease.cpp ggml.o llama.o tests/get_model.cpp $(COMMON_DEPS) $(OBJS) +tests/test-autorelease: tests/test-autorelease.cpp ggml.o llama.o tests/get-model.cpp $(COMMON_DEPS) $(OBJS) $(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS) diff --git a/ci/run.sh b/ci/run.sh index 84a71424c..2427e55a2 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -160,7 +160,7 @@ function gg_run_ctest_with_model_debug { local model; model=$(gg_get_model) cd build-ci-debug set -e - (GG_RUN_CTEST_MODELFILE="$model" time ctest --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log + (LLAMACPP_TEST_MODELFILE="$model" time ctest --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log set +e cd .. } @@ -171,7 +171,7 @@ function gg_run_ctest_with_model_release { local model; model=$(gg_get_model) cd build-ci-release set -e - (GG_RUN_CTEST_MODELFILE="$model" time ctest --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log + (LLAMACPP_TEST_MODELFILE="$model" time ctest --output-on-failure -L model) 2>&1 | tee -a $OUT/${ci}-ctest.log set +e cd .. } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 181da99b1..3e40a78cd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,6 @@ function(llama_build_executable source) get_filename_component(TEST_TARGET ${source} NAME_WE) - add_executable(${TEST_TARGET} ${source} get_model.cpp) + add_executable(${TEST_TARGET} ${source} get-model.cpp) install(TARGETS ${TEST_TARGET} RUNTIME) target_link_libraries(${TEST_TARGET} PRIVATE common) endfunction() @@ -17,7 +17,7 @@ endfunction() function(llama_build_and_test_executable_with_label source label) get_filename_component(TEST_TARGET ${source} NAME_WE) - add_executable(${TEST_TARGET} ${source} get_model.cpp) + add_executable(${TEST_TARGET} ${source} get-model.cpp) install(TARGETS ${TEST_TARGET} RUNTIME) target_link_libraries(${TEST_TARGET} PRIVATE common) add_test(NAME ${TEST_TARGET} COMMAND $ ${ARGN}) diff --git a/tests/get-model.cpp b/tests/get-model.cpp new file mode 100644 index 000000000..4edb685f0 --- /dev/null +++ b/tests/get-model.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +#include "get-model.h" + +char * get_model_or_exit(int argc, char *argv[]) { + char * model_path; + if (argc > 1) { + model_path = argv[1]; + + } else { + model_path = getenv("LLAMACPP_TEST_MODELFILE"); + if (!model_path || strlen(model_path) == 0) { + fprintf(stderr, "\033[33mWARNING: No model file provided. Skipping this test. Set LLAMACPP_TEST_MODELFILE= to silence this warning and run this test.\n\033[0m"); + exit(EXIT_SUCCESS); + } + } + + return model_path; +} diff --git a/tests/get_model.h b/tests/get-model.h similarity index 75% rename from tests/get_model.h rename to tests/get-model.h index 2086b09d0..81a3a0fef 100644 --- a/tests/get_model.h +++ b/tests/get-model.h @@ -1 +1,2 @@ +#pragma once char * get_model_or_exit(int, char*[]); diff --git a/tests/get_model.cpp b/tests/get_model.cpp deleted file mode 100644 index af7b0008f..000000000 --- a/tests/get_model.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include - -#include "get_model.h" - -char * get_model_or_exit(int argc, char *argv[]) { - char * makelevel = getenv("MAKELEVEL"); - if (makelevel != nullptr && atoi(makelevel) > 0) { - fprintf(stderr, "Detected being run in Make. Skipping this test.\n"); - exit(EXIT_SUCCESS); - } - - char * model_path; - if (argc > 1) { - model_path = argv[1]; - } else { - model_path = getenv("GG_RUN_CTEST_MODELFILE"); - if (!model_path || strlen(model_path) == 0) { - fprintf(stderr, "error: no model file provided\n"); - exit(EXIT_FAILURE); - } - } - - return model_path; -} diff --git a/tests/test-autorelease.cpp b/tests/test-autorelease.cpp index af2c2fccf..36a23c0bb 100644 --- a/tests/test-autorelease.cpp +++ b/tests/test-autorelease.cpp @@ -5,7 +5,7 @@ #include #include "llama.h" -#include "get_model.h" +#include "get-model.h" // This creates a new context inside a pthread and then tries to exit cleanly. int main(int argc, char ** argv) { diff --git a/tests/test-model-load-cancel.cpp b/tests/test-model-load-cancel.cpp index b75aa03a8..7ea4bbacc 100644 --- a/tests/test-model-load-cancel.cpp +++ b/tests/test-model-load-cancel.cpp @@ -1,5 +1,5 @@ #include "llama.h" -#include "get_model.h" +#include "get-model.h" #include