Skip to content

Commit 38746d3

Browse files
re-add Windows tmpfile checks in test code
1 parent 5d2a393 commit 38746d3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/test-gguf.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ static void helper_write(FILE * file, const void * data, const size_t nbytes) {
157157
static FILE * get_handcrafted_file(const unsigned int seed, const enum handcrafted_file_type hft, const int extra_bytes = 0) {
158158
FILE * file = tmpfile();
159159

160+
if (!file) {
161+
return file;
162+
}
163+
160164
std::mt19937 rng(seed);
161165
uint32_t alignment = GGUF_DEFAULT_ALIGNMENT;
162166

@@ -693,6 +697,16 @@ static std::pair<int, int> test_handcrafted_file(const unsigned int seed) {
693697
printf("%s: handcrafted_file_type=%s\n", __func__, handcrafted_file_type_name(hft).c_str());
694698
FILE * file = get_handcrafted_file(seed, hft);
695699

700+
#ifdef _WIN32
701+
if (!file) {
702+
printf("%s: failed to create tmpfile(), needs elevated privileges on Windows");
703+
printf("%s: skipping tests");
704+
continue;
705+
}
706+
#else
707+
GGML_ASSERT(file);
708+
#endif // _WIN32
709+
696710
struct ggml_context * ctx = nullptr;
697711
struct gguf_init_params gguf_params = {
698712
/*no_alloc =*/ false,
@@ -1065,6 +1079,17 @@ static std::pair<int, int> test_roundtrip(ggml_backend_dev_t dev, const unsigned
10651079
}
10661080

10671081
FILE * file = tmpfile();
1082+
1083+
#ifdef _WIN32
1084+
if (!file) {
1085+
printf("%s: failed to create tmpfile(), needs elevated privileges on Windows");
1086+
printf("%s: skipping tests");
1087+
return;
1088+
}
1089+
#else
1090+
GGML_ASSERT(file);
1091+
#endif // _WIN32
1092+
10681093
{
10691094
std::vector<int8_t> buf;
10701095
gguf_write_to_buf(gguf_ctx_0, buf, only_meta);

0 commit comments

Comments
 (0)