MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / test_small_chunks

Function test_small_chunks

test/wasmfs/wasmfs_fetch.c:159–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159void test_small_chunks() {
160 // Read the file in small amounts.
161 printf("Running %s...\n", __FUNCTION__);
162
163 char expected[] = "hello";
164 size_t size = 5;
165
166 backend_t backend = wasmfs_create_fetch_backend("small.dat", 2);
167 int fd;
168 char buf[size + 1];
169 fd = wasmfs_create_file("/testfile4", 0777, backend);
170 read_chunks_check(fd, buf, size, 1);
171 buf[size] = 0;
172 printf("buf %s\n",buf);
173 assert(strcmp(buf, "hello") == 0);
174 assert(read(fd, buf, 1024) == 0);
175
176 assert(close(fd) == 0);
177
178 fd = wasmfs_create_file("/testfile5", 0777, backend);
179 read_chunks_check(fd, buf, size, 2);
180 buf[size] = 0;
181 printf("buf %s\n",buf);
182 assert(strcmp(buf, "hello") == 0);
183
184 assert(close(fd) == 0);
185
186 fd = wasmfs_create_file("/testfile6", 0777, backend);
187 read_chunks_check(fd, buf, size, 5);
188 buf[size] = 0;
189 printf("buf %s\n",buf);
190 assert(strcmp(buf, "hello") == 0);
191
192 assert(close(fd) == 0);
193}
194
195void test_small_chunks_divisor_of_size() {
196 printf("Running %s...\n", __FUNCTION__);

Callers 1

mainFunction · 0.85

Calls 8

printfFunction · 0.85
wasmfs_create_fileFunction · 0.85
read_chunks_checkFunction · 0.85
strcmpFunction · 0.85
assertFunction · 0.50
readFunction · 0.50
closeFunction · 0.50

Tested by

no test coverage detected