Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,20 @@ std::string common_get_model_endpoint() {
return model_endpoint;
}

char * common_get_model_or_exit(int argc, char * argv[]) {
if (argc > 1) {
return argv[1];
}

char * path = getenv("LLAMACPP_TEST_MODELFILE");
if (!path || strlen(path) == 0) {
fprintf(stderr, "\033[33mWARNING: No model file provided. Skipping this test. Set LLAMACPP_TEST_MODELFILE=<gguf_model_path> to silence this warning and run this test.\n\033[0m");
exit(EXIT_SUCCESS);
}

return path;
}

common_context_seq_rm_type common_context_can_seq_rm(llama_context * ctx) {
auto * mem = llama_get_memory(ctx);
if (mem == nullptr) {
Expand Down
3 changes: 3 additions & 0 deletions common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,9 @@ void common_set_adapter_lora(struct llama_context * ctx, std::vector<common_adap
// model endpoint from env
std::string common_get_model_endpoint();

// for testing purposes
char * common_get_model_or_exit(int, char*[]);

//
// Context utils
//
Expand Down
7 changes: 4 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function(llama_build_and_test source)
set(multiValueArgs ARGS)
cmake_parse_arguments(LLAMA_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

set(TEST_SOURCES ${source} ${LLAMA_TEST_UNPARSED_ARGUMENTS} get-model.cpp)
set(TEST_SOURCES ${source} ${LLAMA_TEST_UNPARSED_ARGUMENTS})

if (NOT DEFINED LLAMA_TEST_LABEL)
set(LLAMA_TEST_LABEL "main")
Expand Down Expand Up @@ -148,7 +148,7 @@ if (LLAMA_LLGUIDANCE)
llama_build_and_test(test-grammar-llguidance.cpp ARGS ${PROJECT_SOURCE_DIR}/models/ggml-vocab-llama-bpe.gguf)
endif ()

llama_build(test-recurrent-state-rollback.cpp get-model.cpp)
llama_build(test-recurrent-state-rollback.cpp)

if (NOT WIN32 OR NOT BUILD_SHARED_LIBS)
# these tests are disabled on Windows because they use internal functions not exported with LLAMA_API (when building with shared libraries)
Expand Down Expand Up @@ -279,8 +279,9 @@ llama_build_and_test(test-save-load-state.cpp LABEL "model" ARGS -m "${MODEL_DES
set_tests_properties(test-save-load-state PROPERTIES FIXTURES_REQUIRED test-download-model)

if (APPLE)
llama_build(test-rset-release.cpp get-model.cpp)
llama_build(test-rset-release.cpp)
endif()

if (NOT GGML_BACKEND_DL)
# these tests use the backends directly and cannot be built with dynamic loading
llama_build_and_test(test-barrier.cpp)
Expand Down
21 changes: 0 additions & 21 deletions tests/get-model.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions tests/get-model.h

This file was deleted.

6 changes: 2 additions & 4 deletions tests/test-autorelease.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// ref: https://github.com/ggml-org/llama.cpp/issues/4952#issuecomment-1892864763

#include <cstdio>
#include <string>
#include <thread>

#include "llama.h"
#include "get-model.h"
#include "common.h"

// This creates a new context inside a pthread and then tries to exit cleanly.
int main(int argc, char ** argv) {
auto * model_path = get_model_or_exit(argc, argv);
auto * model_path = common_get_model_or_exit(argc, argv);

std::thread([&model_path]() {
llama_backend_init();
Expand Down
3 changes: 1 addition & 2 deletions tests/test-backend-sampler.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "ggml.h"
#include "llama.h"
#include "llama-cpp.h"
#include "get-model.h"
#include "common.h"

#ifdef NDEBUG
Expand Down Expand Up @@ -1136,7 +1135,7 @@ int main(int argc, char ** argv) {
test_args args = parse_cli(argc, argv);

if (args.model.empty()) {
args.model = get_model_or_exit(1, argv);
args.model = common_get_model_or_exit(1, argv);
}

{
Expand Down
4 changes: 2 additions & 2 deletions tests/test-model-load-cancel.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "llama.h"
#include "get-model.h"
#include "common.h"

#include <cstdlib>

int main(int argc, char *argv[] ) {
auto * model_path = get_model_or_exit(argc, argv);
auto * model_path = common_get_model_or_exit(argc, argv);
auto * file = fopen(model_path, "r");
if (file == nullptr) {
fprintf(stderr, "no model at '%s' found\n", model_path);
Expand Down
24 changes: 12 additions & 12 deletions tests/test-quant-type-selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,18 @@ static std::string snapshot_file_from_name(const std::string & name) {
}

static const remote_model_spec model_specs[] = {
{ "ggml-org/Qwen3-0.6B-GGUF", "Q8_0" },
{ "ggml-org/GLM-4.6V-GGUF", "Q8_0" },
{ "ggml-org/Step-3.5-Flash-GGUF", "Q4_K" },
{ "ggml-org/Qwen3-Coder-Next-GGUF", "Q8_0" },
{ "ggml-org/Qwen3-14B-GGUF", "Q8_0" },
{ "ggml-org/Nemotron-Nano-3-30B-A3B-GGUF", "Q8_0" },
{ "ggml-org/gpt-oss-120b-GGUF", "mxfp4" },
{ "ggml-org/gemma-3-4b-it-GGUF", "Q8_0" },
{ "bartowski/Meta-Llama-3.1-70B-Instruct-GGUF", "Q4_K_M" },
{ "bartowski/deepseek-ai_DeepSeek-V3.1-GGUF", "IQ1_M" },
{ "bartowski/Qwen_Qwen3.5-397B-A17B-GGUF", "IQ1_S" }, // TODO: swap with ggml-org if/when it's released
{ "bartowski/Qwen_Qwen3.5-27B-GGUF", "Q8_0" }, // TODO: swap with ggml-org if/when it's released
{ "ggml-org/Qwen3-0.6B-GGUF", "Q8_0" },
{ "ggml-org/GLM-4.6V-GGUF", "Q8_0" },
{ "ggml-org/Step-3.5-Flash-GGUF", "Q4_K" },
{ "ggml-org/Qwen3-Coder-Next-GGUF", "Q8_0" },
{ "ggml-org/Qwen3-14B-GGUF", "Q8_0" },
{ "ggml-org/NVIDIA-Nemotron-Nano-3-30B-A3B-GGUF", "Q8_0" },
{ "ggml-org/gpt-oss-120b-GGUF", "mxfp4" },
{ "ggml-org/gemma-3-4b-it-GGUF", "Q8_0" },
{ "bartowski/Meta-Llama-3.1-70B-Instruct-GGUF", "Q4_K_M" },
{ "bartowski/deepseek-ai_DeepSeek-V3.1-GGUF", "IQ1_M" },
//{ "bartowski/Qwen_Qwen3.5-397B-A17B-GGUF", "IQ1_S" }, // TODO: swap with ggml-org if/when it's released

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bartowski1182 The Qwen3.5-397B quant seems to have changed, so I commented it out to avoid the test failing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed a similar issue with some models in the chat template tests for models that had existed for years, not sure why it happens, no worries, this has lived here long enough to know it works fine without this one model

(aka go ahead and delete the line if you'd like)

{ "ggml-org/Qwen3.6-27B-GGUF", "Q8_0" },
};

static const int n_model_specs = (int) (sizeof(model_specs) / sizeof(model_specs[0]));
Expand Down
8 changes: 4 additions & 4 deletions tests/test-rset-release.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
// thus, this test is not run by default
// example model to run with: google/gemma-4-E4B-it-qat-q4_0-gguf

#include "llama.h"
#include "common.h"

#include <cstdint>
#include <mach/mach.h>
#include <mach/mach_host.h>
#include <unistd.h>

#include "llama.h"
#include "get-model.h"

static uint64_t wired_memory() {
vm_statistics64_data_t vmstat;
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
Expand All @@ -21,7 +21,7 @@ static uint64_t wired_memory() {
}

int main(int argc, char ** argv) {
auto * model_path = get_model_or_exit(argc, argv);
auto * model_path = common_get_model_or_exit(argc, argv);

llama_backend_init();

Expand Down
Loading