aboutsummaryrefslogtreecommitdiff
path: root/tests/test_bf16_model.c
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-06-10 08:57:04 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-06-14 08:27:03 +0200
commit7eaec3a6d01bd598215edd4d6b466f0bf8cec24a (patch)
tree4da6befc90767fcfae70a6a7cd6737915aa3ff30 /tests/test_bf16_model.c
parent6045c430b5f03169e74c9bae77ac5c7992ae7fb0 (diff)
downloadffwd-7eaec3a6d01bd598215edd4d6b466f0bf8cec24a.tar.gz
ffwd-7eaec3a6d01bd598215edd4d6b466f0bf8cec24a.zip
tests: make safetensors and bf16-model tests hermetic, join make test
Diffstat (limited to 'tests/test_bf16_model.c')
-rw-r--r--tests/test_bf16_model.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/test_bf16_model.c b/tests/test_bf16_model.c
index 0f3101a..75d3309 100644
--- a/tests/test_bf16_model.c
+++ b/tests/test_bf16_model.c
@@ -1,21 +1,33 @@
/* tests/test_bf16_model.c - F32 vs BF16 loader/dispatch parity on a tiny
- * synthetic model. Runs via `make test`. */
+ * synthetic model. Hermetic: builds its own model dirs. Runs via
+ * `make test`. */
#include "embed.h"
+#include "tiny_model.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
+#include <sys/stat.h>
+#include <unistd.h>
-int main(int argc, char **argv) {
- if (argc != 3) {
- fprintf(stderr, "usage: %s f32_model bf16_model\n", argv[0]);
+int main(void) {
+ char root[1024], f32_dir[1088], bf16_dir[1088];
+ snprintf(root, sizeof(root), "%s/pplx-bf16-test-XXXXXX",
+ getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp");
+ if (!mkdtemp(root)) { perror("mkdtemp"); return 2; }
+ snprintf(f32_dir, sizeof(f32_dir), "%s/f32", root);
+ snprintf(bf16_dir, sizeof(bf16_dir), "%s/bf16", root);
+ if (mkdir(f32_dir, 0755) != 0 || mkdir(bf16_dir, 0755) != 0 ||
+ tm_write_model(f32_dir, "F32") != 0 ||
+ tm_write_model(bf16_dir, "BF16") != 0) {
+ fprintf(stderr, "fixture creation failed\n");
return 2;
}
int ids[] = {1, 2, 3, 4};
- pplx_model_t *mf32 = pplx_model_load(argv[1]);
- pplx_model_t *mbf16 = pplx_model_load(argv[2]);
+ pplx_model_t *mf32 = pplx_model_load(f32_dir);
+ pplx_model_t *mbf16 = pplx_model_load(bf16_dir);
if (!mf32 || !mbf16) {
fprintf(stderr, "model load failed\n");
return 1;