summaryrefslogtreecommitdiff
path: root/tests/test-model-load-cancel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-model-load-cancel.cpp')
-rw-r--r--tests/test-model-load-cancel.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test-model-load-cancel.cpp b/tests/test-model-load-cancel.cpp
new file mode 100644
index 00000000..7ea4bbac
--- /dev/null
+++ b/tests/test-model-load-cancel.cpp
@@ -0,0 +1,27 @@
+#include "llama.h"
+#include "get-model.h"
+
+#include <cstdlib>
+
+int main(int argc, char *argv[] ) {
+ auto * model_path = 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);
+ return EXIT_FAILURE;
+ }
+
+ fprintf(stderr, "using '%s'\n", model_path);
+ fclose(file);
+
+ llama_backend_init(false);
+ auto params = llama_model_params{};
+ params.use_mmap = false;
+ params.progress_callback = [](float progress, void * ctx){
+ (void) ctx;
+ return progress > 0.50;
+ };
+ auto * model = llama_load_model_from_file(model_path, params);
+ llama_backend_free();
+ return model == nullptr ? EXIT_SUCCESS : EXIT_FAILURE;
+}