mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 08:42:40 +01:00 
			
		
		
		
	Generated v2 prefixes
This commit is contained in:
		
							
								
								
									
										16
									
								
								.travis.yml
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								.travis.yml
									
									
									
									
									
								
							| @@ -23,8 +23,20 @@ script: | |||||||
|   - make test QUIET=1 CFLAGS+="-DLFS2_BLOCK_COUNT=1023 -DLFS2_LOOKAHEAD_SIZE=256" |   - make test QUIET=1 CFLAGS+="-DLFS2_BLOCK_COUNT=1023 -DLFS2_LOOKAHEAD_SIZE=256" | ||||||
|  |  | ||||||
|   - make clean test QUIET=1 CFLAGS+="-DLFS2_INLINE_MAX=0" |   - make clean test QUIET=1 CFLAGS+="-DLFS2_INLINE_MAX=0" | ||||||
|  |   - make clean test QUIET=1 CFLAGS+="-DLFS2_EMUBD_ERASE_VALUE=0xff" | ||||||
|   - make clean test QUIET=1 CFLAGS+="-DLFS2_NO_INTRINSICS" |   - make clean test QUIET=1 CFLAGS+="-DLFS2_NO_INTRINSICS" | ||||||
|  |  | ||||||
|  |   # additional configurations that don't support all tests (this should be | ||||||
|  |   # fixed but at the moment it is what it is) | ||||||
|  |   - make test_files QUIET=1 | ||||||
|  |         CFLAGS+="-DLFS2_READ_SIZE=1 -DLFS2_BLOCK_SIZE=4096" | ||||||
|  |   - make test_files QUIET=1 | ||||||
|  |         CFLAGS+="-DLFS2_READ_SIZE=\(2*1024\) -DLFS2_BLOCK_SIZE=\(64*1024\)" | ||||||
|  |   - make test_files QUIET=1 | ||||||
|  |         CFLAGS+="-DLFS2_READ_SIZE=\(8*1024\) -DLFS2_BLOCK_SIZE=\(64*1024\)" | ||||||
|  |   - make test_files QUIET=1 | ||||||
|  |         CFLAGS+="-DLFS2_READ_SIZE=11 -DLFS2_BLOCK_SIZE=704" | ||||||
|  |  | ||||||
|   # compile and find the code size with the smallest configuration |   # compile and find the code size with the smallest configuration | ||||||
|   - make clean size |   - make clean size | ||||||
|         OBJ="$(ls lfs2*.o | tr '\n' ' ')" |         OBJ="$(ls lfs2*.o | tr '\n' ' ')" | ||||||
| @@ -111,7 +123,7 @@ jobs: | |||||||
|       if: branch !~ -prefix$ |       if: branch !~ -prefix$ | ||||||
|       install: |       install: | ||||||
|         - sudo apt-get install libfuse-dev |         - sudo apt-get install libfuse-dev | ||||||
|         - git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2-alpha |         - git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2 | ||||||
|         - fusermount -V |         - fusermount -V | ||||||
|         - gcc --version |         - gcc --version | ||||||
|       before_script: |       before_script: | ||||||
| @@ -146,7 +158,7 @@ jobs: | |||||||
|       if: branch !~ -prefix$ |       if: branch !~ -prefix$ | ||||||
|       install: |       install: | ||||||
|         - sudo apt-get install libfuse-dev |         - sudo apt-get install libfuse-dev | ||||||
|         - git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2-alpha v2 |         - git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2 v2 | ||||||
|         - git clone --depth 1 https://github.com/geky/littlefs-fuse -b v1 v1 |         - git clone --depth 1 https://github.com/geky/littlefs-fuse -b v1 v1 | ||||||
|         - fusermount -V |         - fusermount -V | ||||||
|         - gcc --version |         - gcc --version | ||||||
|   | |||||||
							
								
								
									
										22
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								Makefile
									
									
									
									
									
								
							| @@ -24,6 +24,9 @@ endif | |||||||
| ifdef WORD | ifdef WORD | ||||||
| override CFLAGS += -m$(WORD) | override CFLAGS += -m$(WORD) | ||||||
| endif | endif | ||||||
|  | ifdef TRACE | ||||||
|  | override CFLAGS += -DLFS2_YES_TRACE | ||||||
|  | endif | ||||||
| override CFLAGS += -I. | override CFLAGS += -I. | ||||||
| override CFLAGS += -std=c99 -Wall -pedantic | override CFLAGS += -std=c99 -Wall -pedantic | ||||||
| override CFLAGS += -Wextra -Wshadow -Wjump-misses-init | override CFLAGS += -Wextra -Wshadow -Wjump-misses-init | ||||||
| @@ -39,14 +42,25 @@ size: $(OBJ) | |||||||
| 	$(SIZE) -t $^ | 	$(SIZE) -t $^ | ||||||
|  |  | ||||||
| .SUFFIXES: | .SUFFIXES: | ||||||
| test: test_format test_dirs test_files test_seek test_truncate \ | test: \ | ||||||
| 	test_entries test_interspersed test_alloc test_paths test_attrs \ | 	test_format \ | ||||||
| 	test_move test_orphan test_corrupt | 	test_dirs \ | ||||||
|  | 	test_files \ | ||||||
|  | 	test_seek \ | ||||||
|  | 	test_truncate \ | ||||||
|  | 	test_entries \ | ||||||
|  | 	test_interspersed \ | ||||||
|  | 	test_alloc \ | ||||||
|  | 	test_paths \ | ||||||
|  | 	test_attrs \ | ||||||
|  | 	test_move \ | ||||||
|  | 	test_orphan \ | ||||||
|  | 	test_corrupt | ||||||
| 	@rm test.c | 	@rm test.c | ||||||
| test_%: tests/test_%.sh | test_%: tests/test_%.sh | ||||||
|  |  | ||||||
| ifdef QUIET | ifdef QUIET | ||||||
| 	@./$< | sed -n '/^[-=]/p' | 	@./$< | sed -nu '/^[-=]/p' | ||||||
| else | else | ||||||
| 	./$< | 	./$< | ||||||
| endif | endif | ||||||
|   | |||||||
| @@ -11,7 +11,6 @@ | |||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <limits.h> | #include <limits.h> | ||||||
| #include <dirent.h> |  | ||||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| #include <assert.h> | #include <assert.h> | ||||||
| @@ -55,6 +54,15 @@ static inline void lfs2_emubd_fromle32(lfs2_emubd_t *emu) { | |||||||
|  |  | ||||||
| // Block device emulated on existing filesystem | // Block device emulated on existing filesystem | ||||||
| int lfs2_emubd_create(const struct lfs2_config *cfg, const char *path) { | int lfs2_emubd_create(const struct lfs2_config *cfg, const char *path) { | ||||||
|  |     LFS2_TRACE("lfs2_emubd_create(%p {.context=%p, " | ||||||
|  |                 ".read=%p, .prog=%p, .erase=%p, .sync=%p, " | ||||||
|  |                 ".read_size=%"PRIu32", .prog_size=%"PRIu32", " | ||||||
|  |                 ".block_size=%"PRIu32", .block_count=%"PRIu32"}, \"%s\")", | ||||||
|  |             (void*)cfg, cfg->context, | ||||||
|  |             (void*)(uintptr_t)cfg->read, (void*)(uintptr_t)cfg->prog, | ||||||
|  |             (void*)(uintptr_t)cfg->erase, (void*)(uintptr_t)cfg->sync, | ||||||
|  |             cfg->read_size, cfg->prog_size, cfg->block_size, cfg->block_count, | ||||||
|  |             path); | ||||||
|     lfs2_emubd_t *emu = cfg->context; |     lfs2_emubd_t *emu = cfg->context; | ||||||
|     emu->cfg.read_size   = cfg->read_size; |     emu->cfg.read_size   = cfg->read_size; | ||||||
|     emu->cfg.prog_size   = cfg->prog_size; |     emu->cfg.prog_size   = cfg->prog_size; | ||||||
| @@ -65,7 +73,9 @@ int lfs2_emubd_create(const struct lfs2_config *cfg, const char *path) { | |||||||
|     size_t pathlen = strlen(path); |     size_t pathlen = strlen(path); | ||||||
|     emu->path = malloc(pathlen + 1 + LFS2_NAME_MAX + 1); |     emu->path = malloc(pathlen + 1 + LFS2_NAME_MAX + 1); | ||||||
|     if (!emu->path) { |     if (!emu->path) { | ||||||
|         return -ENOMEM; |         int err = -ENOMEM; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_create -> %"PRId32, err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     strcpy(emu->path, path); |     strcpy(emu->path, path); | ||||||
| @@ -76,24 +86,30 @@ int lfs2_emubd_create(const struct lfs2_config *cfg, const char *path) { | |||||||
|     // Create directory if it doesn't exist |     // Create directory if it doesn't exist | ||||||
|     int err = mkdir(path, 0777); |     int err = mkdir(path, 0777); | ||||||
|     if (err && errno != EEXIST) { |     if (err && errno != EEXIST) { | ||||||
|         return -errno; |         err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_create -> %"PRId32, err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Load stats to continue incrementing |     // Load stats to continue incrementing | ||||||
|     snprintf(emu->child, LFS2_NAME_MAX, ".stats"); |     snprintf(emu->child, LFS2_NAME_MAX, ".stats"); | ||||||
|     FILE *f = fopen(emu->path, "r"); |     FILE *f = fopen(emu->path, "r"); | ||||||
|     if (!f) { |     if (!f) { | ||||||
|         memset(&emu->stats, 0, sizeof(emu->stats)); |         memset(&emu->stats, LFS2_EMUBD_ERASE_VALUE, sizeof(emu->stats)); | ||||||
|     } else { |     } else { | ||||||
|         size_t res = fread(&emu->stats, sizeof(emu->stats), 1, f); |         size_t res = fread(&emu->stats, sizeof(emu->stats), 1, f); | ||||||
|         lfs2_emubd_fromle32(emu); |         lfs2_emubd_fromle32(emu); | ||||||
|         if (res < 1) { |         if (res < 1) { | ||||||
|             return -errno; |             err = -errno; | ||||||
|  |             LFS2_TRACE("lfs2_emubd_create -> %"PRId32, err); | ||||||
|  |             return err; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         err = fclose(f); |         err = fclose(f); | ||||||
|         if (err) { |         if (err) { | ||||||
|             return -errno; |             err = -errno; | ||||||
|  |             LFS2_TRACE("lfs2_emubd_create -> %"PRId32, err); | ||||||
|  |             return err; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -106,27 +122,36 @@ int lfs2_emubd_create(const struct lfs2_config *cfg, const char *path) { | |||||||
|         size_t res = fread(&emu->history, sizeof(emu->history), 1, f); |         size_t res = fread(&emu->history, sizeof(emu->history), 1, f); | ||||||
|         lfs2_emubd_fromle32(emu); |         lfs2_emubd_fromle32(emu); | ||||||
|         if (res < 1) { |         if (res < 1) { | ||||||
|             return -errno; |             err = -errno; | ||||||
|  |             LFS2_TRACE("lfs2_emubd_create -> %"PRId32, err); | ||||||
|  |             return err; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         err = fclose(f); |         err = fclose(f); | ||||||
|         if (err) { |         if (err) { | ||||||
|             return -errno; |             err = -errno; | ||||||
|  |             LFS2_TRACE("lfs2_emubd_create -> %"PRId32, err); | ||||||
|  |             return err; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     LFS2_TRACE("lfs2_emubd_create -> %"PRId32, 0); | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void lfs2_emubd_destroy(const struct lfs2_config *cfg) { | void lfs2_emubd_destroy(const struct lfs2_config *cfg) { | ||||||
|  |     LFS2_TRACE("lfs2_emubd_destroy(%p)", (void*)cfg); | ||||||
|     lfs2_emubd_sync(cfg); |     lfs2_emubd_sync(cfg); | ||||||
|  |  | ||||||
|     lfs2_emubd_t *emu = cfg->context; |     lfs2_emubd_t *emu = cfg->context; | ||||||
|     free(emu->path); |     free(emu->path); | ||||||
|  |     LFS2_TRACE("lfs2_emubd_destroy -> %s", "void"); | ||||||
| } | } | ||||||
|  |  | ||||||
| int lfs2_emubd_read(const struct lfs2_config *cfg, lfs2_block_t block, | int lfs2_emubd_read(const struct lfs2_config *cfg, lfs2_block_t block, | ||||||
|         lfs2_off_t off, void *buffer, lfs2_size_t size) { |         lfs2_off_t off, void *buffer, lfs2_size_t size) { | ||||||
|  |     LFS2_TRACE("lfs2_emubd_read(%p, 0x%"PRIx32", %"PRIu32", %p, %"PRIu32")", | ||||||
|  |             (void*)cfg, block, off, buffer, size); | ||||||
|     lfs2_emubd_t *emu = cfg->context; |     lfs2_emubd_t *emu = cfg->context; | ||||||
|     uint8_t *data = buffer; |     uint8_t *data = buffer; | ||||||
|  |  | ||||||
| @@ -143,32 +168,43 @@ int lfs2_emubd_read(const struct lfs2_config *cfg, lfs2_block_t block, | |||||||
|  |  | ||||||
|     FILE *f = fopen(emu->path, "rb"); |     FILE *f = fopen(emu->path, "rb"); | ||||||
|     if (!f && errno != ENOENT) { |     if (!f && errno != ENOENT) { | ||||||
|         return -errno; |         int err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_read -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (f) { |     if (f) { | ||||||
|         int err = fseek(f, off, SEEK_SET); |         int err = fseek(f, off, SEEK_SET); | ||||||
|         if (err) { |         if (err) { | ||||||
|             return -errno; |             err = -errno; | ||||||
|  |             LFS2_TRACE("lfs2_emubd_read -> %d", err); | ||||||
|  |             return err; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         size_t res = fread(data, 1, size, f); |         size_t res = fread(data, 1, size, f); | ||||||
|         if (res < size && !feof(f)) { |         if (res < size && !feof(f)) { | ||||||
|             return -errno; |             err = -errno; | ||||||
|  |             LFS2_TRACE("lfs2_emubd_read -> %d", err); | ||||||
|  |             return err; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         err = fclose(f); |         err = fclose(f); | ||||||
|         if (err) { |         if (err) { | ||||||
|             return -errno; |             err = -errno; | ||||||
|  |             LFS2_TRACE("lfs2_emubd_read -> %d", err); | ||||||
|  |             return err; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     emu->stats.read_count += 1; |     emu->stats.read_count += size; | ||||||
|  |     LFS2_TRACE("lfs2_emubd_read -> %d", 0); | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| int lfs2_emubd_prog(const struct lfs2_config *cfg, lfs2_block_t block, | int lfs2_emubd_prog(const struct lfs2_config *cfg, lfs2_block_t block, | ||||||
|         lfs2_off_t off, const void *buffer, lfs2_size_t size) { |         lfs2_off_t off, const void *buffer, lfs2_size_t size) { | ||||||
|  |     LFS2_TRACE("lfs2_emubd_prog(%p, 0x%"PRIx32", %"PRIu32", %p, %"PRIu32")", | ||||||
|  |             (void*)cfg, block, off, buffer, size); | ||||||
|     lfs2_emubd_t *emu = cfg->context; |     lfs2_emubd_t *emu = cfg->context; | ||||||
|     const uint8_t *data = buffer; |     const uint8_t *data = buffer; | ||||||
|  |  | ||||||
| @@ -182,7 +218,9 @@ int lfs2_emubd_prog(const struct lfs2_config *cfg, lfs2_block_t block, | |||||||
|  |  | ||||||
|     FILE *f = fopen(emu->path, "r+b"); |     FILE *f = fopen(emu->path, "r+b"); | ||||||
|     if (!f) { |     if (!f) { | ||||||
|         return (errno == EACCES) ? 0 : -errno; |         int err = (errno == EACCES) ? 0 : -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_prog -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Check that file was erased |     // Check that file was erased | ||||||
| @@ -190,42 +228,54 @@ int lfs2_emubd_prog(const struct lfs2_config *cfg, lfs2_block_t block, | |||||||
|  |  | ||||||
|     int err = fseek(f, off, SEEK_SET); |     int err = fseek(f, off, SEEK_SET); | ||||||
|     if (err) { |     if (err) { | ||||||
|         return -errno; |         err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_prog -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     size_t res = fwrite(data, 1, size, f); |     size_t res = fwrite(data, 1, size, f); | ||||||
|     if (res < size) { |     if (res < size) { | ||||||
|         return -errno; |         err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_prog -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     err = fseek(f, off, SEEK_SET); |     err = fseek(f, off, SEEK_SET); | ||||||
|     if (err) { |     if (err) { | ||||||
|         return -errno; |         err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_prog -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     uint8_t dat; |     uint8_t dat; | ||||||
|     res = fread(&dat, 1, 1, f); |     res = fread(&dat, 1, 1, f); | ||||||
|     if (res < 1) { |     if (res < 1) { | ||||||
|         return -errno; |         err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_prog -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     err = fclose(f); |     err = fclose(f); | ||||||
|     if (err) { |     if (err) { | ||||||
|         return -errno; |         err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_prog -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // update history and stats |     // update history and stats | ||||||
|     if (block != emu->history.blocks[0]) { |     if (block != emu->history.blocks[0]) { | ||||||
|         memcpy(&emu->history.blocks[1], &emu->history.blocks[0], |         memmove(&emu->history.blocks[1], &emu->history.blocks[0], | ||||||
|                 sizeof(emu->history) - sizeof(emu->history.blocks[0])); |                 sizeof(emu->history) - sizeof(emu->history.blocks[0])); | ||||||
|         emu->history.blocks[0] = block; |         emu->history.blocks[0] = block; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     emu->stats.prog_count += 1; |     emu->stats.prog_count += size; | ||||||
|  |     LFS2_TRACE("lfs2_emubd_prog -> %d", 0); | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| int lfs2_emubd_erase(const struct lfs2_config *cfg, lfs2_block_t block) { | int lfs2_emubd_erase(const struct lfs2_config *cfg, lfs2_block_t block) { | ||||||
|  |     LFS2_TRACE("lfs2_emubd_erase(%p, 0x%"PRIx32")", (void*)cfg, block); | ||||||
|     lfs2_emubd_t *emu = cfg->context; |     lfs2_emubd_t *emu = cfg->context; | ||||||
|  |  | ||||||
|     // Check if erase is valid |     // Check if erase is valid | ||||||
| @@ -236,89 +286,118 @@ int lfs2_emubd_erase(const struct lfs2_config *cfg, lfs2_block_t block) { | |||||||
|     struct stat st; |     struct stat st; | ||||||
|     int err = stat(emu->path, &st); |     int err = stat(emu->path, &st); | ||||||
|     if (err && errno != ENOENT) { |     if (err && errno != ENOENT) { | ||||||
|         return -errno; |         err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_erase -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (!err && S_ISREG(st.st_mode) && (S_IWUSR & st.st_mode)) { |     if (!err && S_ISREG(st.st_mode) && (S_IWUSR & st.st_mode)) { | ||||||
|         err = unlink(emu->path); |         err = unlink(emu->path); | ||||||
|         if (err) { |         if (err) { | ||||||
|             return -errno; |             err = -errno; | ||||||
|  |             LFS2_TRACE("lfs2_emubd_erase -> %d", err); | ||||||
|  |             return err; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (err || (S_ISREG(st.st_mode) && (S_IWUSR & st.st_mode))) { |     if (err || (S_ISREG(st.st_mode) && (S_IWUSR & st.st_mode))) { | ||||||
|         FILE *f = fopen(emu->path, "w"); |         FILE *f = fopen(emu->path, "w"); | ||||||
|         if (!f) { |         if (!f) { | ||||||
|             return -errno; |             err = -errno; | ||||||
|  |             LFS2_TRACE("lfs2_emubd_erase -> %d", err); | ||||||
|  |             return err; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         err = fclose(f); |         err = fclose(f); | ||||||
|         if (err) { |         if (err) { | ||||||
|             return -errno; |             err = -errno; | ||||||
|  |             LFS2_TRACE("lfs2_emubd_erase -> %d", err); | ||||||
|  |             return err; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     emu->stats.erase_count += 1; |     emu->stats.erase_count += cfg->block_size; | ||||||
|  |     LFS2_TRACE("lfs2_emubd_erase -> %d", 0); | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| int lfs2_emubd_sync(const struct lfs2_config *cfg) { | int lfs2_emubd_sync(const struct lfs2_config *cfg) { | ||||||
|  |     LFS2_TRACE("lfs2_emubd_sync(%p)", (void*)cfg); | ||||||
|     lfs2_emubd_t *emu = cfg->context; |     lfs2_emubd_t *emu = cfg->context; | ||||||
|  |  | ||||||
|     // Just write out info/stats for later lookup |     // Just write out info/stats for later lookup | ||||||
|     snprintf(emu->child, LFS2_NAME_MAX, ".config"); |     snprintf(emu->child, LFS2_NAME_MAX, ".config"); | ||||||
|     FILE *f = fopen(emu->path, "w"); |     FILE *f = fopen(emu->path, "w"); | ||||||
|     if (!f) { |     if (!f) { | ||||||
|         return -errno; |         int err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_sync -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_emubd_tole32(emu); |     lfs2_emubd_tole32(emu); | ||||||
|     size_t res = fwrite(&emu->cfg, sizeof(emu->cfg), 1, f); |     size_t res = fwrite(&emu->cfg, sizeof(emu->cfg), 1, f); | ||||||
|     lfs2_emubd_fromle32(emu); |     lfs2_emubd_fromle32(emu); | ||||||
|     if (res < 1) { |     if (res < 1) { | ||||||
|         return -errno; |         int err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_sync -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     int err = fclose(f); |     int err = fclose(f); | ||||||
|     if (err) { |     if (err) { | ||||||
|         return -errno; |         err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_sync -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     snprintf(emu->child, LFS2_NAME_MAX, ".stats"); |     snprintf(emu->child, LFS2_NAME_MAX, ".stats"); | ||||||
|     f = fopen(emu->path, "w"); |     f = fopen(emu->path, "w"); | ||||||
|     if (!f) { |     if (!f) { | ||||||
|         return -errno; |         err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_sync -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_emubd_tole32(emu); |     lfs2_emubd_tole32(emu); | ||||||
|     res = fwrite(&emu->stats, sizeof(emu->stats), 1, f); |     res = fwrite(&emu->stats, sizeof(emu->stats), 1, f); | ||||||
|     lfs2_emubd_fromle32(emu); |     lfs2_emubd_fromle32(emu); | ||||||
|     if (res < 1) { |     if (res < 1) { | ||||||
|         return -errno; |         err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_sync -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     err = fclose(f); |     err = fclose(f); | ||||||
|     if (err) { |     if (err) { | ||||||
|         return -errno; |         err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_sync -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     snprintf(emu->child, LFS2_NAME_MAX, ".history"); |     snprintf(emu->child, LFS2_NAME_MAX, ".history"); | ||||||
|     f = fopen(emu->path, "w"); |     f = fopen(emu->path, "w"); | ||||||
|     if (!f) { |     if (!f) { | ||||||
|         return -errno; |         err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_sync -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_emubd_tole32(emu); |     lfs2_emubd_tole32(emu); | ||||||
|     res = fwrite(&emu->history, sizeof(emu->history), 1, f); |     res = fwrite(&emu->history, sizeof(emu->history), 1, f); | ||||||
|     lfs2_emubd_fromle32(emu); |     lfs2_emubd_fromle32(emu); | ||||||
|     if (res < 1) { |     if (res < 1) { | ||||||
|         return -errno; |         err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_sync -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     err = fclose(f); |     err = fclose(f); | ||||||
|     if (err) { |     if (err) { | ||||||
|         return -errno; |         err = -errno; | ||||||
|  |         LFS2_TRACE("lfs2_emubd_sync -> %d", err); | ||||||
|  |         return err; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     LFS2_TRACE("lfs2_emubd_sync -> %d", 0); | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -17,20 +17,8 @@ extern "C" | |||||||
|  |  | ||||||
|  |  | ||||||
| // Config options | // Config options | ||||||
| #ifndef LFS2_EMUBD_READ_SIZE | #ifndef LFS2_EMUBD_ERASE_VALUE | ||||||
| #define LFS2_EMUBD_READ_SIZE 1 | #define LFS2_EMUBD_ERASE_VALUE 0x00 | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #ifndef LFS2_EMUBD_PROG_SIZE |  | ||||||
| #define LFS2_EMUBD_PROG_SIZE 1 |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #ifndef LFS2_EMUBD_ERASE_SIZE |  | ||||||
| #define LFS2_EMUBD_ERASE_SIZE 512 |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #ifndef LFS2_EMUBD_TOTAL_SIZE |  | ||||||
| #define LFS2_EMUBD_TOTAL_SIZE 524288 |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										21
									
								
								lfs2.h
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								lfs2.h
									
									
									
									
									
								
							| @@ -21,7 +21,7 @@ extern "C" | |||||||
| // Software library version | // Software library version | ||||||
| // Major (top-nibble), incremented on backwards incompatible changes | // Major (top-nibble), incremented on backwards incompatible changes | ||||||
| // Minor (bottom-nibble), incremented on feature additions | // Minor (bottom-nibble), incremented on feature additions | ||||||
| #define LFS2_VERSION 0x00020000 | #define LFS2_VERSION 0x00020001 | ||||||
| #define LFS2_VERSION_MAJOR (0xffff & (LFS2_VERSION >> 16)) | #define LFS2_VERSION_MAJOR (0xffff & (LFS2_VERSION >> 16)) | ||||||
| #define LFS2_VERSION_MINOR (0xffff & (LFS2_VERSION >>  0)) | #define LFS2_VERSION_MINOR (0xffff & (LFS2_VERSION >>  0)) | ||||||
|  |  | ||||||
| @@ -136,6 +136,7 @@ enum lfs2_open_flags { | |||||||
|     LFS2_F_READING = 0x040000, // File has been read since last flush |     LFS2_F_READING = 0x040000, // File has been read since last flush | ||||||
|     LFS2_F_ERRED   = 0x080000, // An error occured during write |     LFS2_F_ERRED   = 0x080000, // An error occured during write | ||||||
|     LFS2_F_INLINE  = 0x100000, // Currently inlined in directory entry |     LFS2_F_INLINE  = 0x100000, // Currently inlined in directory entry | ||||||
|  |     LFS2_F_OPENED  = 0x200000, // File has been opened | ||||||
| }; | }; | ||||||
|  |  | ||||||
| // File seek flags | // File seek flags | ||||||
| @@ -190,9 +191,13 @@ struct lfs2_config { | |||||||
|     // Number of erasable blocks on the device. |     // Number of erasable blocks on the device. | ||||||
|     lfs2_size_t block_count; |     lfs2_size_t block_count; | ||||||
|  |  | ||||||
|     // Number of erase cycles before we should move data to another block. |     // Number of erase cycles before littlefs evicts metadata logs and moves  | ||||||
|     // May be zero, in which case no block-level wear-leveling is performed. |     // the metadata to another block. Suggested values are in the | ||||||
|     uint32_t block_cycles; |     // range 100-1000, with large values having better performance at the cost | ||||||
|  |     // of less consistent wear distribution. | ||||||
|  |     // | ||||||
|  |     // Set to -1 to disable block-level wear-leveling. | ||||||
|  |     int32_t block_cycles; | ||||||
|  |  | ||||||
|     // Size of block caches. Each cache buffers a portion of a block in RAM. |     // Size of block caches. Each cache buffers a portion of a block in RAM. | ||||||
|     // The littlefs needs a read cache, a program cache, and one additional |     // The littlefs needs a read cache, a program cache, and one additional | ||||||
| @@ -204,7 +209,7 @@ struct lfs2_config { | |||||||
|     // Size of the lookahead buffer in bytes. A larger lookahead buffer |     // Size of the lookahead buffer in bytes. A larger lookahead buffer | ||||||
|     // increases the number of blocks found during an allocation pass. The |     // increases the number of blocks found during an allocation pass. The | ||||||
|     // lookahead buffer is stored as a compact bitmap, so each byte of RAM |     // lookahead buffer is stored as a compact bitmap, so each byte of RAM | ||||||
|     // can track 8 blocks. Must be a multiple of 4. |     // can track 8 blocks. Must be a multiple of 8. | ||||||
|     lfs2_size_t lookahead_size; |     lfs2_size_t lookahead_size; | ||||||
|  |  | ||||||
|     // Optional statically allocated read buffer. Must be cache_size. |     // Optional statically allocated read buffer. Must be cache_size. | ||||||
| @@ -216,7 +221,7 @@ struct lfs2_config { | |||||||
|     void *prog_buffer; |     void *prog_buffer; | ||||||
|  |  | ||||||
|     // Optional statically allocated lookahead buffer. Must be lookahead_size |     // Optional statically allocated lookahead buffer. Must be lookahead_size | ||||||
|     // and aligned to a 64-bit boundary. By default lfs2_malloc is used to |     // and aligned to a 32-bit boundary. By default lfs2_malloc is used to | ||||||
|     // allocate this buffer. |     // allocate this buffer. | ||||||
|     void *lookahead_buffer; |     void *lookahead_buffer; | ||||||
|  |  | ||||||
| @@ -528,7 +533,7 @@ lfs2_ssize_t lfs2_file_write(lfs2_t *lfs2, lfs2_file_t *file, | |||||||
| // Change the position of the file | // Change the position of the file | ||||||
| // | // | ||||||
| // The change in position is determined by the offset and whence flag. | // The change in position is determined by the offset and whence flag. | ||||||
| // Returns the old position of the file, or a negative error code on failure. | // Returns the new position of the file, or a negative error code on failure. | ||||||
| lfs2_soff_t lfs2_file_seek(lfs2_t *lfs2, lfs2_file_t *file, | lfs2_soff_t lfs2_file_seek(lfs2_t *lfs2, lfs2_file_t *file, | ||||||
|         lfs2_soff_t off, int whence); |         lfs2_soff_t off, int whence); | ||||||
|  |  | ||||||
| @@ -545,7 +550,7 @@ lfs2_soff_t lfs2_file_tell(lfs2_t *lfs2, lfs2_file_t *file); | |||||||
|  |  | ||||||
| // Change the position of the file to the beginning of the file | // Change the position of the file to the beginning of the file | ||||||
| // | // | ||||||
| // Equivalent to lfs2_file_seek(lfs2, file, 0, LFS2_SEEK_CUR) | // Equivalent to lfs2_file_seek(lfs2, file, 0, LFS2_SEEK_SET) | ||||||
| // Returns a negative error code on failure. | // Returns a negative error code on failure. | ||||||
| int lfs2_file_rewind(lfs2_t *lfs2, lfs2_file_t *file); | int lfs2_file_rewind(lfs2_t *lfs2, lfs2_file_t *file); | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										18
									
								
								lfs2_util.h
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								lfs2_util.h
									
									
									
									
									
								
							| @@ -31,7 +31,10 @@ | |||||||
| #ifndef LFS2_NO_ASSERT | #ifndef LFS2_NO_ASSERT | ||||||
| #include <assert.h> | #include <assert.h> | ||||||
| #endif | #endif | ||||||
| #if !defined(LFS2_NO_DEBUG) || !defined(LFS2_NO_WARN) || !defined(LFS2_NO_ERROR) | #if !defined(LFS2_NO_DEBUG) || \ | ||||||
|  |         !defined(LFS2_NO_WARN) || \ | ||||||
|  |         !defined(LFS2_NO_ERROR) || \ | ||||||
|  |         defined(LFS2_YES_TRACE) | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -46,23 +49,30 @@ extern "C" | |||||||
| // code footprint | // code footprint | ||||||
|  |  | ||||||
| // Logging functions | // Logging functions | ||||||
|  | #ifdef LFS2_YES_TRACE | ||||||
|  | #define LFS2_TRACE(fmt, ...) \ | ||||||
|  |     printf("lfs2_trace:%d: " fmt "\n", __LINE__, __VA_ARGS__) | ||||||
|  | #else | ||||||
|  | #define LFS2_TRACE(fmt, ...) | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #ifndef LFS2_NO_DEBUG | #ifndef LFS2_NO_DEBUG | ||||||
| #define LFS2_DEBUG(fmt, ...) \ | #define LFS2_DEBUG(fmt, ...) \ | ||||||
|     printf("lfs2 debug:%d: " fmt "\n", __LINE__, __VA_ARGS__) |     printf("lfs2_debug:%d: " fmt "\n", __LINE__, __VA_ARGS__) | ||||||
| #else | #else | ||||||
| #define LFS2_DEBUG(fmt, ...) | #define LFS2_DEBUG(fmt, ...) | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifndef LFS2_NO_WARN | #ifndef LFS2_NO_WARN | ||||||
| #define LFS2_WARN(fmt, ...) \ | #define LFS2_WARN(fmt, ...) \ | ||||||
|     printf("lfs2 warn:%d: " fmt "\n", __LINE__, __VA_ARGS__) |     printf("lfs2_warn:%d: " fmt "\n", __LINE__, __VA_ARGS__) | ||||||
| #else | #else | ||||||
| #define LFS2_WARN(fmt, ...) | #define LFS2_WARN(fmt, ...) | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifndef LFS2_NO_ERROR | #ifndef LFS2_NO_ERROR | ||||||
| #define LFS2_ERROR(fmt, ...) \ | #define LFS2_ERROR(fmt, ...) \ | ||||||
|     printf("lfs2 error:%d: " fmt "\n", __LINE__, __VA_ARGS__) |     printf("lfs2_error:%d: " fmt "\n", __LINE__, __VA_ARGS__) | ||||||
| #else | #else | ||||||
| #define LFS2_ERROR(fmt, ...) | #define LFS2_ERROR(fmt, ...) | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -95,7 +95,7 @@ def main(*blocks): | |||||||
|         print '%04x: %08x  %-15s %3s %4s  %-23s  %-8s' % ( |         print '%04x: %08x  %-15s %3s %4s  %-23s  %-8s' % ( | ||||||
|             off, tag, |             off, tag, | ||||||
|             typeof(type) + (' bad!' if iscrc and ~crc else ''), |             typeof(type) + (' bad!' if iscrc and ~crc else ''), | ||||||
|             id if id != 0x3ff else '.', |             hex(id)[2:] if id != 0x3ff else '.', | ||||||
|             size if size != 0x3ff else 'x', |             size if size != 0x3ff else 'x', | ||||||
|             ' '.join('%02x' % ord(c) for c in data[:8]), |             ' '.join('%02x' % ord(c) for c in data[:8]), | ||||||
|             ''.join(c if c >= ' ' and c <= '~' else '.' for c in data[:8])) |             ''.join(c if c >= ' ' and c <= '~' else '.' for c in data[:8])) | ||||||
							
								
								
									
										28
									
								
								scripts/results.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										28
									
								
								scripts/results.py
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,28 @@ | |||||||
|  | #!/usr/bin/env python2 | ||||||
|  |  | ||||||
|  | import struct | ||||||
|  | import sys | ||||||
|  | import time | ||||||
|  | import os | ||||||
|  | import re | ||||||
|  |  | ||||||
|  | def main(): | ||||||
|  |     with open('blocks/.config') as file: | ||||||
|  |         read_size, prog_size, block_size, block_count = ( | ||||||
|  |             struct.unpack('<LLLL', file.read())) | ||||||
|  |  | ||||||
|  |     real_size = sum( | ||||||
|  |         os.path.getsize(os.path.join('blocks', f)) | ||||||
|  |         for f in os.listdir('blocks') if re.match('\d+', f)) | ||||||
|  |  | ||||||
|  |     with open('blocks/.stats') as file: | ||||||
|  |         read_count, prog_count, erase_count = ( | ||||||
|  |             struct.unpack('<QQQ', file.read())) | ||||||
|  |  | ||||||
|  |     runtime = time.time() - os.stat('blocks').st_ctime | ||||||
|  |  | ||||||
|  |     print 'results: %dB %dB %dB %.3fs' % ( | ||||||
|  |         read_count, prog_count, erase_count, runtime) | ||||||
|  |  | ||||||
|  | if __name__ == "__main__": | ||||||
|  |     main(*sys.argv[1:]) | ||||||
| @@ -7,34 +7,21 @@ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // test stuff | // test stuff | ||||||
| static void test_log(const char *s, uintmax_t v) {{ |  | ||||||
|     printf("%s: %jd\n", s, v); |  | ||||||
| }} |  | ||||||
| 
 |  | ||||||
| static void test_assert(const char *file, unsigned line, | static void test_assert(const char *file, unsigned line, | ||||||
|         const char *s, uintmax_t v, uintmax_t e) {{ |         const char *s, uintmax_t v, uintmax_t e) {{ | ||||||
|     static const char *last[6] = {{0, 0}}; |  | ||||||
|     if (v != e || !(last[0] == s || last[1] == s || |  | ||||||
|             last[2] == s || last[3] == s || |  | ||||||
|             last[4] == s || last[5] == s)) {{ |  | ||||||
|         test_log(s, v); |  | ||||||
|         last[0] = last[1]; |  | ||||||
|         last[1] = last[2]; |  | ||||||
|         last[2] = last[3]; |  | ||||||
|         last[3] = last[4]; |  | ||||||
|         last[4] = last[5]; |  | ||||||
|         last[5] = s; |  | ||||||
|     }} |  | ||||||
| 
 |  | ||||||
|     if (v != e) {{ |     if (v != e) {{ | ||||||
|         fprintf(stderr, "\033[31m%s:%u: assert %s failed with %jd, " |         fprintf(stderr, "\033[97m%s:%u: \033[91m" | ||||||
|                 "expected %jd\033[0m\n", file, line, s, v, e); |                 "assert failed with %jd, expected %jd\033[0m\n" | ||||||
|  |                 "    %s\n\n", file, line, v, e, s); | ||||||
|         exit(-2); |         exit(-2); | ||||||
|     }} |     }} | ||||||
| }} | }} | ||||||
| 
 | 
 | ||||||
| #define test_assert(s, v, e) test_assert(__FILE__, __LINE__, s, v, e) | #define test_assert(v, e) \ | ||||||
|  |         test_assert(__FILE__, __LINE__, #v " => " #e, v, e) | ||||||
| 
 | 
 | ||||||
|  | // implicit variable for asserts | ||||||
|  | uintmax_t test; | ||||||
| 
 | 
 | ||||||
| // utility functions for traversals | // utility functions for traversals | ||||||
| static int __attribute__((used)) test_count(void *p, lfs2_block_t b) {{ | static int __attribute__((used)) test_count(void *p, lfs2_block_t b) {{ | ||||||
| @@ -44,23 +31,17 @@ static int __attribute__((used)) test_count(void *p, lfs2_block_t b) {{ | |||||||
|     return 0; |     return 0; | ||||||
| }} | }} | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| // lfs2 declarations | // lfs2 declarations | ||||||
| lfs2_t lfs2; | lfs2_t lfs2; | ||||||
| lfs2_emubd_t bd; | lfs2_emubd_t bd; | ||||||
| lfs2_file_t file[4]; | // other declarations for convenience | ||||||
| lfs2_dir_t dir[4]; | lfs2_file_t file; | ||||||
|  | lfs2_dir_t dir; | ||||||
| struct lfs2_info info; | struct lfs2_info info; | ||||||
| 
 |  | ||||||
| uint8_t buffer[1024]; | uint8_t buffer[1024]; | ||||||
| uint8_t wbuffer[1024]; | char path[1024]; | ||||||
| uint8_t rbuffer[1024]; |  | ||||||
| lfs2_size_t size; |  | ||||||
| lfs2_size_t wsize; |  | ||||||
| lfs2_size_t rsize; |  | ||||||
| 
 |  | ||||||
| uintmax_t test; |  | ||||||
| 
 | 
 | ||||||
|  | // test configuration options | ||||||
| #ifndef LFS2_READ_SIZE | #ifndef LFS2_READ_SIZE | ||||||
| #define LFS2_READ_SIZE 16 | #define LFS2_READ_SIZE 16 | ||||||
| #endif | #endif | ||||||
| @@ -82,7 +63,7 @@ uintmax_t test; | |||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifndef LFS2_CACHE_SIZE | #ifndef LFS2_CACHE_SIZE | ||||||
| #define LFS2_CACHE_SIZE 64 | #define LFS2_CACHE_SIZE (64 % LFS2_PROG_SIZE == 0 ? 64 : LFS2_PROG_SIZE) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #ifndef LFS2_LOOKAHEAD_SIZE | #ifndef LFS2_LOOKAHEAD_SIZE | ||||||
| @@ -111,6 +92,5 @@ int main(void) {{ | |||||||
|     lfs2_emubd_create(&cfg, "blocks"); |     lfs2_emubd_create(&cfg, "blocks"); | ||||||
| 
 | 
 | ||||||
| {tests} | {tests} | ||||||
| 
 |  | ||||||
|     lfs2_emubd_destroy(&cfg); |     lfs2_emubd_destroy(&cfg); | ||||||
| }} | }} | ||||||
							
								
								
									
										81
									
								
								scripts/test.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										81
									
								
								scripts/test.py
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,81 @@ | |||||||
|  | #!/usr/bin/env python2 | ||||||
|  |  | ||||||
|  | import re | ||||||
|  | import sys | ||||||
|  | import subprocess | ||||||
|  | import os | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def generate(test): | ||||||
|  |     with open("scripts/template.fmt") as file: | ||||||
|  |         template = file.read() | ||||||
|  |  | ||||||
|  |     haslines = 'TEST_LINE' in os.environ and 'TEST_FILE' in os.environ | ||||||
|  |  | ||||||
|  |     lines = [] | ||||||
|  |     for offset, line in enumerate( | ||||||
|  |             re.split('(?<=(?:.;| [{}]))\n', test.read())): | ||||||
|  |         match = re.match('((?: *\n)*)( *)(.*)=>(.*);', | ||||||
|  |                 line, re.DOTALL | re.MULTILINE) | ||||||
|  |         if match: | ||||||
|  |             preface, tab, test, expect = match.groups() | ||||||
|  |             lines.extend(['']*preface.count('\n')) | ||||||
|  |             lines.append(tab+'test_assert({test}, {expect});'.format( | ||||||
|  |                 test=test.strip(), expect=expect.strip())) | ||||||
|  |         else: | ||||||
|  |             lines.append(line) | ||||||
|  |  | ||||||
|  |     # Create test file | ||||||
|  |     with open('test.c', 'w') as file: | ||||||
|  |         if 'TEST_LINE' in os.environ and 'TEST_FILE' in os.environ: | ||||||
|  |             lines.insert(0, '#line %d "%s"' % ( | ||||||
|  |                     int(os.environ['TEST_LINE']) + 1, | ||||||
|  |                     os.environ['TEST_FILE'])) | ||||||
|  |             lines.append('#line %d "test.c"' % ( | ||||||
|  |                     template[:template.find('{tests}')].count('\n') | ||||||
|  |                     + len(lines) + 2)) | ||||||
|  |  | ||||||
|  |         file.write(template.format(tests='\n'.join(lines))) | ||||||
|  |  | ||||||
|  |     # Remove build artifacts to force rebuild | ||||||
|  |     try: | ||||||
|  |         os.remove('test.o') | ||||||
|  |         os.remove('lfs2') | ||||||
|  |     except OSError: | ||||||
|  |         pass | ||||||
|  |  | ||||||
|  | def compile(): | ||||||
|  |     subprocess.check_call([ | ||||||
|  |             os.environ.get('MAKE', 'make'), | ||||||
|  |             '--no-print-directory', '-s']) | ||||||
|  |  | ||||||
|  | def execute(): | ||||||
|  |     if 'EXEC' in os.environ: | ||||||
|  |         subprocess.check_call([os.environ['EXEC'], "./lfs2"]) | ||||||
|  |     else: | ||||||
|  |         subprocess.check_call(["./lfs2"]) | ||||||
|  |  | ||||||
|  | def main(test=None): | ||||||
|  |     try: | ||||||
|  |         if test and not test.startswith('-'): | ||||||
|  |             with open(test) as file: | ||||||
|  |                 generate(file) | ||||||
|  |         else: | ||||||
|  |             generate(sys.stdin) | ||||||
|  |  | ||||||
|  |         compile() | ||||||
|  |  | ||||||
|  |         if test == '-s': | ||||||
|  |             sys.exit(1) | ||||||
|  |  | ||||||
|  |         execute() | ||||||
|  |  | ||||||
|  |     except subprocess.CalledProcessError: | ||||||
|  |         # Python stack trace is counterproductive, just exit | ||||||
|  |         sys.exit(2) | ||||||
|  |     except KeyboardInterrupt: | ||||||
|  |         # Python stack trace is counterproductive, just exit | ||||||
|  |         sys.exit(3) | ||||||
|  |  | ||||||
|  | if __name__ == "__main__": | ||||||
|  |     main(*sys.argv[1:]) | ||||||
| @@ -1,30 +0,0 @@ | |||||||
| #!/usr/bin/env python2 |  | ||||||
|  |  | ||||||
| import struct |  | ||||||
| import sys |  | ||||||
| import time |  | ||||||
| import os |  | ||||||
| import re |  | ||||||
|  |  | ||||||
| def main(): |  | ||||||
|     with open('blocks/.config') as file: |  | ||||||
|         s = struct.unpack('<LLLL', file.read()) |  | ||||||
|         print 'read_size: %d' % s[0] |  | ||||||
|         print 'prog_size: %d' % s[1] |  | ||||||
|         print 'block_size: %d' % s[2] |  | ||||||
|         print 'block_size: %d' % s[3] |  | ||||||
|  |  | ||||||
|     print 'real_size: %d' % sum( |  | ||||||
|         os.path.getsize(os.path.join('blocks', f)) |  | ||||||
|         for f in os.listdir('blocks') if re.match('\d+', f)) |  | ||||||
|  |  | ||||||
|     with open('blocks/.stats') as file: |  | ||||||
|         s = struct.unpack('<QQQ', file.read()) |  | ||||||
|         print 'read_count: %d' % s[0] |  | ||||||
|         print 'prog_count: %d' % s[1] |  | ||||||
|         print 'erase_count: %d' % s[2] |  | ||||||
|  |  | ||||||
|     print 'runtime: %.3f' % (time.time() - os.stat('blocks').st_ctime) |  | ||||||
|  |  | ||||||
| if __name__ == "__main__": |  | ||||||
|     main(*sys.argv[1:]) |  | ||||||
| @@ -1,61 +0,0 @@ | |||||||
| #!/usr/bin/env python2 |  | ||||||
|  |  | ||||||
| import re |  | ||||||
| import sys |  | ||||||
| import subprocess |  | ||||||
| import os |  | ||||||
|  |  | ||||||
| def generate(test): |  | ||||||
|     with open("tests/template.fmt") as file: |  | ||||||
|         template = file.read() |  | ||||||
|  |  | ||||||
|     lines = [] |  | ||||||
|     for line in re.split('(?<=(?:.;| [{}]))\n', test.read()): |  | ||||||
|         match = re.match('(?: *\n)*( *)(.*)=>(.*);', line, re.DOTALL | re.MULTILINE) |  | ||||||
|         if match: |  | ||||||
|             tab, test, expect = match.groups() |  | ||||||
|             lines.append(tab+'test = {test};'.format(test=test.strip())) |  | ||||||
|             lines.append(tab+'test_assert("{name}", test, {expect});'.format( |  | ||||||
|                     name = re.match('\w*', test.strip()).group(), |  | ||||||
|                     expect = expect.strip())) |  | ||||||
|         else: |  | ||||||
|             lines.append(line) |  | ||||||
|  |  | ||||||
|     # Create test file |  | ||||||
|     with open('test.c', 'w') as file: |  | ||||||
|         file.write(template.format(tests='\n'.join(lines))) |  | ||||||
|  |  | ||||||
|     # Remove build artifacts to force rebuild |  | ||||||
|     try: |  | ||||||
|         os.remove('test.o') |  | ||||||
|         os.remove('lfs2') |  | ||||||
|     except OSError: |  | ||||||
|         pass |  | ||||||
|  |  | ||||||
| def compile(): |  | ||||||
|     subprocess.check_call([ |  | ||||||
|             os.environ.get('MAKE', 'make'), |  | ||||||
|             '--no-print-directory', '-s']) |  | ||||||
|  |  | ||||||
| def execute(): |  | ||||||
|     if 'EXEC' in os.environ: |  | ||||||
|         subprocess.check_call([os.environ['EXEC'], "./lfs2"]) |  | ||||||
|     else: |  | ||||||
|         subprocess.check_call(["./lfs2"]) |  | ||||||
|  |  | ||||||
| def main(test=None): |  | ||||||
|     if test and not test.startswith('-'): |  | ||||||
|         with open(test) as file: |  | ||||||
|             generate(file) |  | ||||||
|     else: |  | ||||||
|         generate(sys.stdin) |  | ||||||
|  |  | ||||||
|     compile() |  | ||||||
|  |  | ||||||
|     if test == '-s': |  | ||||||
|         sys.exit(1) |  | ||||||
|  |  | ||||||
|     execute() |  | ||||||
|  |  | ||||||
| if __name__ == "__main__": |  | ||||||
|     main(*sys.argv[1:]) |  | ||||||
| @@ -1,16 +1,18 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| set -eu | set -euE | ||||||
|  | export TEST_FILE=$0 | ||||||
|  | trap 'export TEST_LINE=$LINENO' DEBUG | ||||||
|  |  | ||||||
| echo "=== Allocator tests ===" | echo "=== Allocator tests ===" | ||||||
| rm -rf blocks | rm -rf blocks | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| SIZE=15000 | SIZE=15000 | ||||||
|  |  | ||||||
| lfs2_mkdir() { | lfs2_mkdir() { | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "$1") => 0; |     lfs2_mkdir(&lfs2, "$1") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| @@ -18,7 +20,7 @@ TEST | |||||||
| } | } | ||||||
|  |  | ||||||
| lfs2_remove() { | lfs2_remove() { | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_remove(&lfs2, "$1/eggs") => 0; |     lfs2_remove(&lfs2, "$1/eggs") => 0; | ||||||
|     lfs2_remove(&lfs2, "$1/bacon") => 0; |     lfs2_remove(&lfs2, "$1/bacon") => 0; | ||||||
| @@ -29,22 +31,23 @@ TEST | |||||||
| } | } | ||||||
|  |  | ||||||
| lfs2_alloc_singleproc() { | lfs2_alloc_singleproc() { | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     const char *names[] = {"bacon", "eggs", "pancakes"}; |     const char *names[] = {"bacon", "eggs", "pancakes"}; | ||||||
|  |     lfs2_file_t files[sizeof(names)/sizeof(names[0])]; | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     for (unsigned n = 0; n < sizeof(names)/sizeof(names[0]); n++) { |     for (unsigned n = 0; n < sizeof(names)/sizeof(names[0]); n++) { | ||||||
|         sprintf((char*)buffer, "$1/%s", names[n]); |         sprintf(path, "$1/%s", names[n]); | ||||||
|         lfs2_file_open(&lfs2, &file[n], (char*)buffer, |         lfs2_file_open(&lfs2, &files[n], path, | ||||||
|                 LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_APPEND) => 0; |                 LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_APPEND) => 0; | ||||||
|     } |     } | ||||||
|     for (unsigned n = 0; n < sizeof(names)/sizeof(names[0]); n++) { |     for (unsigned n = 0; n < sizeof(names)/sizeof(names[0]); n++) { | ||||||
|         size = strlen(names[n]); |         lfs2_size_t size = strlen(names[n]); | ||||||
|         for (int i = 0; i < $SIZE; i++) { |         for (int i = 0; i < $SIZE; i++) { | ||||||
|             lfs2_file_write(&lfs2, &file[n], names[n], size) => size; |             lfs2_file_write(&lfs2, &files[n], names[n], size) => size; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     for (unsigned n = 0; n < sizeof(names)/sizeof(names[0]); n++) { |     for (unsigned n = 0; n < sizeof(names)/sizeof(names[0]); n++) { | ||||||
|         lfs2_file_close(&lfs2, &file[n]) => 0; |         lfs2_file_close(&lfs2, &files[n]) => 0; | ||||||
|     } |     } | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| @@ -53,16 +56,16 @@ TEST | |||||||
| lfs2_alloc_multiproc() { | lfs2_alloc_multiproc() { | ||||||
| for name in bacon eggs pancakes | for name in bacon eggs pancakes | ||||||
| do | do | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "$1/$name", |     lfs2_file_open(&lfs2, &file, "$1/$name", | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_APPEND) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_APPEND) => 0; | ||||||
|     size = strlen("$name"); |     lfs2_size_t size = strlen("$name"); | ||||||
|     memcpy(buffer, "$name", size); |     memcpy(buffer, "$name", size); | ||||||
|     for (int i = 0; i < $SIZE; i++) { |     for (int i = 0; i < $SIZE; i++) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| done | done | ||||||
| @@ -71,15 +74,15 @@ done | |||||||
| lfs2_verify() { | lfs2_verify() { | ||||||
| for name in bacon eggs pancakes | for name in bacon eggs pancakes | ||||||
| do | do | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "$1/$name", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &file, "$1/$name", LFS2_O_RDONLY) => 0; | ||||||
|     size = strlen("$name"); |     lfs2_size_t size = strlen("$name"); | ||||||
|     for (int i = 0; i < $SIZE; i++) { |     for (int i = 0; i < $SIZE; i++) { | ||||||
|         lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|         memcmp(buffer, "$name", size) => 0; |         memcmp(buffer, "$name", size) => 0; | ||||||
|     } |     } | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| done | done | ||||||
| @@ -115,19 +118,19 @@ lfs2_remove multiprocreuse | |||||||
| lfs2_remove singleprocreuse | lfs2_remove singleprocreuse | ||||||
|  |  | ||||||
| echo "--- Exhaustion test ---" | echo "--- Exhaustion test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); |     lfs2_file_open(&lfs2, &file, "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); | ||||||
|     size = strlen("exhaustion"); |     lfs2_size_t size = strlen("exhaustion"); | ||||||
|     memcpy(buffer, "exhaustion", size); |     memcpy(buffer, "exhaustion", size); | ||||||
|     lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     lfs2_file_sync(&lfs2, &file[0]) => 0; |     lfs2_file_sync(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     size = strlen("blahblahblahblah"); |     size = strlen("blahblahblahblah"); | ||||||
|     memcpy(buffer, "blahblahblahblah", size); |     memcpy(buffer, "blahblahblahblah", size); | ||||||
|     lfs2_ssize_t res; |     lfs2_ssize_t res; | ||||||
|     while (true) { |     while (true) { | ||||||
|         res = lfs2_file_write(&lfs2, &file[0], buffer, size); |         res = lfs2_file_write(&lfs2, &file, buffer, size); | ||||||
|         if (res < 0) { |         if (res < 0) { | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| @@ -136,45 +139,45 @@ tests/test.py << TEST | |||||||
|     } |     } | ||||||
|     res => LFS2_ERR_NOSPC; |     res => LFS2_ERR_NOSPC; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion", LFS2_O_RDONLY); |     lfs2_file_open(&lfs2, &file, "exhaustion", LFS2_O_RDONLY); | ||||||
|     size = strlen("exhaustion"); |     lfs2_size_t size = strlen("exhaustion"); | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => size; |     lfs2_file_size(&lfs2, &file) => size; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "exhaustion", size) => 0; |     memcmp(buffer, "exhaustion", size) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Exhaustion wraparound test ---" | echo "--- Exhaustion wraparound test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_remove(&lfs2, "exhaustion") => 0; |     lfs2_remove(&lfs2, "exhaustion") => 0; | ||||||
|  |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], "padding", LFS2_O_WRONLY | LFS2_O_CREAT); |     lfs2_file_open(&lfs2, &file, "padding", LFS2_O_WRONLY | LFS2_O_CREAT); | ||||||
|     size = strlen("buffering"); |     lfs2_size_t size = strlen("buffering"); | ||||||
|     memcpy(buffer, "buffering", size); |     memcpy(buffer, "buffering", size); | ||||||
|     for (int i = 0; i < $SIZE; i++) { |     for (int i = 0; i < $SIZE; i++) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_remove(&lfs2, "padding") => 0; |     lfs2_remove(&lfs2, "padding") => 0; | ||||||
|  |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); |     lfs2_file_open(&lfs2, &file, "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); | ||||||
|     size = strlen("exhaustion"); |     size = strlen("exhaustion"); | ||||||
|     memcpy(buffer, "exhaustion", size); |     memcpy(buffer, "exhaustion", size); | ||||||
|     lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     lfs2_file_sync(&lfs2, &file[0]) => 0; |     lfs2_file_sync(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     size = strlen("blahblahblahblah"); |     size = strlen("blahblahblahblah"); | ||||||
|     memcpy(buffer, "blahblahblahblah", size); |     memcpy(buffer, "blahblahblahblah", size); | ||||||
|     lfs2_ssize_t res; |     lfs2_ssize_t res; | ||||||
|     while (true) { |     while (true) { | ||||||
|         res = lfs2_file_write(&lfs2, &file[0], buffer, size); |         res = lfs2_file_write(&lfs2, &file, buffer, size); | ||||||
|         if (res < 0) { |         if (res < 0) { | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| @@ -183,34 +186,34 @@ tests/test.py << TEST | |||||||
|     } |     } | ||||||
|     res => LFS2_ERR_NOSPC; |     res => LFS2_ERR_NOSPC; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion", LFS2_O_RDONLY); |     lfs2_file_open(&lfs2, &file, "exhaustion", LFS2_O_RDONLY); | ||||||
|     size = strlen("exhaustion"); |     lfs2_size_t size = strlen("exhaustion"); | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => size; |     lfs2_file_size(&lfs2, &file) => size; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "exhaustion", size) => 0; |     memcmp(buffer, "exhaustion", size) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_remove(&lfs2, "exhaustion") => 0; |     lfs2_remove(&lfs2, "exhaustion") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Dir exhaustion test ---" | echo "--- Dir exhaustion test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     // find out max file size |     // find out max file size | ||||||
|     lfs2_mkdir(&lfs2, "exhaustiondir") => 0; |     lfs2_mkdir(&lfs2, "exhaustiondir") => 0; | ||||||
|     size = strlen("blahblahblahblah"); |     lfs2_size_t size = strlen("blahblahblahblah"); | ||||||
|     memcpy(buffer, "blahblahblahblah", size); |     memcpy(buffer, "blahblahblahblah", size); | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); |     lfs2_file_open(&lfs2, &file, "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); | ||||||
|     int count = 0; |     int count = 0; | ||||||
|     int err; |     int err; | ||||||
|     while (true) { |     while (true) { | ||||||
|         err = lfs2_file_write(&lfs2, &file[0], buffer, size); |         err = lfs2_file_write(&lfs2, &file, buffer, size); | ||||||
|         if (err < 0) { |         if (err < 0) { | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| @@ -218,28 +221,28 @@ tests/test.py << TEST | |||||||
|         count += 1; |         count += 1; | ||||||
|     } |     } | ||||||
|     err => LFS2_ERR_NOSPC; |     err => LFS2_ERR_NOSPC; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     lfs2_remove(&lfs2, "exhaustion") => 0; |     lfs2_remove(&lfs2, "exhaustion") => 0; | ||||||
|     lfs2_remove(&lfs2, "exhaustiondir") => 0; |     lfs2_remove(&lfs2, "exhaustiondir") => 0; | ||||||
|  |  | ||||||
|     // see if dir fits with max file size |     // see if dir fits with max file size | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); |     lfs2_file_open(&lfs2, &file, "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); | ||||||
|     for (int i = 0; i < count; i++) { |     for (int i = 0; i < count; i++) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     lfs2_mkdir(&lfs2, "exhaustiondir") => 0; |     lfs2_mkdir(&lfs2, "exhaustiondir") => 0; | ||||||
|     lfs2_remove(&lfs2, "exhaustiondir") => 0; |     lfs2_remove(&lfs2, "exhaustiondir") => 0; | ||||||
|     lfs2_remove(&lfs2, "exhaustion") => 0; |     lfs2_remove(&lfs2, "exhaustion") => 0; | ||||||
|  |  | ||||||
|     // see if dir fits with > max file size |     // see if dir fits with > max file size | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); |     lfs2_file_open(&lfs2, &file, "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); | ||||||
|     for (int i = 0; i < count+1; i++) { |     for (int i = 0; i < count+1; i++) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     lfs2_mkdir(&lfs2, "exhaustiondir") => LFS2_ERR_NOSPC; |     lfs2_mkdir(&lfs2, "exhaustiondir") => LFS2_ERR_NOSPC; | ||||||
|  |  | ||||||
| @@ -248,22 +251,22 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Chained dir exhaustion test ---" | echo "--- Chained dir exhaustion test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     // find out max file size |     // find out max file size | ||||||
|     lfs2_mkdir(&lfs2, "exhaustiondir") => 0; |     lfs2_mkdir(&lfs2, "exhaustiondir") => 0; | ||||||
|     for (int i = 0; i < 10; i++) { |     for (int i = 0; i < 10; i++) { | ||||||
|         sprintf((char*)buffer, "dirwithanexhaustivelylongnameforpadding%d", i); |         sprintf(path, "dirwithanexhaustivelylongnameforpadding%d", i); | ||||||
|         lfs2_mkdir(&lfs2, (char*)buffer) => 0; |         lfs2_mkdir(&lfs2, path) => 0; | ||||||
|     } |     } | ||||||
|     size = strlen("blahblahblahblah"); |     lfs2_size_t size = strlen("blahblahblahblah"); | ||||||
|     memcpy(buffer, "blahblahblahblah", size); |     memcpy(buffer, "blahblahblahblah", size); | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); |     lfs2_file_open(&lfs2, &file, "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); | ||||||
|     int count = 0; |     int count = 0; | ||||||
|     int err; |     int err; | ||||||
|     while (true) { |     while (true) { | ||||||
|         err = lfs2_file_write(&lfs2, &file[0], buffer, size); |         err = lfs2_file_write(&lfs2, &file, buffer, size); | ||||||
|         if (err < 0) { |         if (err < 0) { | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
| @@ -271,25 +274,25 @@ tests/test.py << TEST | |||||||
|         count += 1; |         count += 1; | ||||||
|     } |     } | ||||||
|     err => LFS2_ERR_NOSPC; |     err => LFS2_ERR_NOSPC; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     lfs2_remove(&lfs2, "exhaustion") => 0; |     lfs2_remove(&lfs2, "exhaustion") => 0; | ||||||
|     lfs2_remove(&lfs2, "exhaustiondir") => 0; |     lfs2_remove(&lfs2, "exhaustiondir") => 0; | ||||||
|     for (int i = 0; i < 10; i++) { |     for (int i = 0; i < 10; i++) { | ||||||
|         sprintf((char*)buffer, "dirwithanexhaustivelylongnameforpadding%d", i); |         sprintf(path, "dirwithanexhaustivelylongnameforpadding%d", i); | ||||||
|         lfs2_remove(&lfs2, (char*)buffer) => 0; |         lfs2_remove(&lfs2, path) => 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // see that chained dir fails |     // see that chained dir fails | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); |     lfs2_file_open(&lfs2, &file, "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); | ||||||
|     for (int i = 0; i < count+1; i++) { |     for (int i = 0; i < count+1; i++) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_sync(&lfs2, &file[0]) => 0; |     lfs2_file_sync(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     for (int i = 0; i < 10; i++) { |     for (int i = 0; i < 10; i++) { | ||||||
|         sprintf((char*)buffer, "dirwithanexhaustivelylongnameforpadding%d", i); |         sprintf(path, "dirwithanexhaustivelylongnameforpadding%d", i); | ||||||
|         lfs2_mkdir(&lfs2, (char*)buffer) => 0; |         lfs2_mkdir(&lfs2, path) => 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_mkdir(&lfs2, "exhaustiondir") => LFS2_ERR_NOSPC; |     lfs2_mkdir(&lfs2, "exhaustiondir") => LFS2_ERR_NOSPC; | ||||||
| @@ -301,45 +304,44 @@ tests/test.py << TEST | |||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         lfs2_ssize_t filesize = lfs2_file_size(&lfs2, &file[0]); |         lfs2_ssize_t filesize = lfs2_file_size(&lfs2, &file); | ||||||
|         filesize > 0 => true; |         filesize > 0 => true; | ||||||
|  |  | ||||||
|         lfs2_file_truncate(&lfs2, &file[0], filesize - size) => 0; |         lfs2_file_truncate(&lfs2, &file, filesize - size) => 0; | ||||||
|         lfs2_file_sync(&lfs2, &file[0]) => 0; |         lfs2_file_sync(&lfs2, &file) => 0; | ||||||
|     } |     } | ||||||
|     err => 0; |     err => 0; | ||||||
|  |  | ||||||
|     lfs2_mkdir(&lfs2, "exhaustiondir2") => LFS2_ERR_NOSPC; |     lfs2_mkdir(&lfs2, "exhaustiondir2") => LFS2_ERR_NOSPC; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Split dir test ---" | echo "--- Split dir test ---" | ||||||
| rm -rf blocks | scripts/test.py << TEST | ||||||
| tests/test.py << TEST |  | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     // create one block hole for half a directory |     // create one block hole for half a directory | ||||||
|     lfs2_file_open(&lfs2, &file[0], "bump", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |     lfs2_file_open(&lfs2, &file, "bump", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|     for (lfs2_size_t i = 0; i < cfg.block_size; i += 2) { |     for (lfs2_size_t i = 0; i < cfg.block_size; i += 2) { | ||||||
|         memcpy(&buffer[i], "hi", 2); |         memcpy(&buffer[i], "hi", 2); | ||||||
|     } |     } | ||||||
|     lfs2_file_write(&lfs2, &file[0], buffer, cfg.block_size) => cfg.block_size; |     lfs2_file_write(&lfs2, &file, buffer, cfg.block_size) => cfg.block_size; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); |     lfs2_file_open(&lfs2, &file, "exhaustion", LFS2_O_WRONLY | LFS2_O_CREAT); | ||||||
|     size = strlen("blahblahblahblah"); |     lfs2_size_t size = strlen("blahblahblahblah"); | ||||||
|     memcpy(buffer, "blahblahblahblah", size); |     memcpy(buffer, "blahblahblahblah", size); | ||||||
|     for (lfs2_size_t i = 0; |     for (lfs2_size_t i = 0; | ||||||
|             i < (cfg.block_count-4)*(cfg.block_size-8); |             i < (cfg.block_count-4)*(cfg.block_size-8); | ||||||
|             i += size) { |             i += size) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     // remount to force reset of lookahead |     // remount to force reset of lookahead | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| @@ -349,137 +351,134 @@ tests/test.py << TEST | |||||||
|     lfs2_remove(&lfs2, "bump") => 0; |     lfs2_remove(&lfs2, "bump") => 0; | ||||||
|  |  | ||||||
|     lfs2_mkdir(&lfs2, "splitdir") => 0; |     lfs2_mkdir(&lfs2, "splitdir") => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "splitdir/bump", |     lfs2_file_open(&lfs2, &file, "splitdir/bump", | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|     for (lfs2_size_t i = 0; i < cfg.block_size; i += 2) { |     for (lfs2_size_t i = 0; i < cfg.block_size; i += 2) { | ||||||
|         memcpy(&buffer[i], "hi", 2); |         memcpy(&buffer[i], "hi", 2); | ||||||
|     } |     } | ||||||
|     lfs2_file_write(&lfs2, &file[0], buffer, 2*cfg.block_size) => LFS2_ERR_NOSPC; |     lfs2_file_write(&lfs2, &file, buffer, 2*cfg.block_size) => LFS2_ERR_NOSPC; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Outdated lookahead test ---" | echo "--- Outdated lookahead test ---" | ||||||
| rm -rf blocks | scripts/test.py << TEST | ||||||
| tests/test.py << TEST |  | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     // fill completely with two files |     // fill completely with two files | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion1", |     lfs2_file_open(&lfs2, &file, "exhaustion1", | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|     size = strlen("blahblahblahblah"); |     lfs2_size_t size = strlen("blahblahblahblah"); | ||||||
|     memcpy(buffer, "blahblahblahblah", size); |     memcpy(buffer, "blahblahblahblah", size); | ||||||
|     for (lfs2_size_t i = 0; |     for (lfs2_size_t i = 0; | ||||||
|             i < ((cfg.block_count-2)/2)*(cfg.block_size-8); |             i < ((cfg.block_count-2)/2)*(cfg.block_size-8); | ||||||
|             i += size) { |             i += size) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion2", |     lfs2_file_open(&lfs2, &file, "exhaustion2", | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|     size = strlen("blahblahblahblah"); |     size = strlen("blahblahblahblah"); | ||||||
|     memcpy(buffer, "blahblahblahblah", size); |     memcpy(buffer, "blahblahblahblah", size); | ||||||
|     for (lfs2_size_t i = 0; |     for (lfs2_size_t i = 0; | ||||||
|             i < ((cfg.block_count-2+1)/2)*(cfg.block_size-8); |             i < ((cfg.block_count-2+1)/2)*(cfg.block_size-8); | ||||||
|             i += size) { |             i += size) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     // remount to force reset of lookahead |     // remount to force reset of lookahead | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     // rewrite one file |     // rewrite one file | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion1", |     lfs2_file_open(&lfs2, &file, "exhaustion1", | ||||||
|             LFS2_O_WRONLY | LFS2_O_TRUNC) => 0; |             LFS2_O_WRONLY | LFS2_O_TRUNC) => 0; | ||||||
|     lfs2_file_sync(&lfs2, &file[0]) => 0; |     lfs2_file_sync(&lfs2, &file) => 0; | ||||||
|     size = strlen("blahblahblahblah"); |     size = strlen("blahblahblahblah"); | ||||||
|     memcpy(buffer, "blahblahblahblah", size); |     memcpy(buffer, "blahblahblahblah", size); | ||||||
|     for (lfs2_size_t i = 0; |     for (lfs2_size_t i = 0; | ||||||
|             i < ((cfg.block_count-2)/2)*(cfg.block_size-8); |             i < ((cfg.block_count-2)/2)*(cfg.block_size-8); | ||||||
|             i += size) { |             i += size) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     // rewrite second file, this requires lookahead does not |     // rewrite second file, this requires lookahead does not | ||||||
|     // use old population |     // use old population | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion2", |     lfs2_file_open(&lfs2, &file, "exhaustion2", | ||||||
|             LFS2_O_WRONLY | LFS2_O_TRUNC) => 0; |             LFS2_O_WRONLY | LFS2_O_TRUNC) => 0; | ||||||
|     lfs2_file_sync(&lfs2, &file[0]) => 0; |     lfs2_file_sync(&lfs2, &file) => 0; | ||||||
|     size = strlen("blahblahblahblah"); |     size = strlen("blahblahblahblah"); | ||||||
|     memcpy(buffer, "blahblahblahblah", size); |     memcpy(buffer, "blahblahblahblah", size); | ||||||
|     for (lfs2_size_t i = 0; |     for (lfs2_size_t i = 0; | ||||||
|             i < ((cfg.block_count-2+1)/2)*(cfg.block_size-8); |             i < ((cfg.block_count-2+1)/2)*(cfg.block_size-8); | ||||||
|             i += size) { |             i += size) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Outdated lookahead and split dir test ---" | echo "--- Outdated lookahead and split dir test ---" | ||||||
| rm -rf blocks | scripts/test.py << TEST | ||||||
| tests/test.py << TEST |  | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     // fill completely with two files |     // fill completely with two files | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion1", |     lfs2_file_open(&lfs2, &file, "exhaustion1", | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|     size = strlen("blahblahblahblah"); |     lfs2_size_t size = strlen("blahblahblahblah"); | ||||||
|     memcpy(buffer, "blahblahblahblah", size); |     memcpy(buffer, "blahblahblahblah", size); | ||||||
|     for (lfs2_size_t i = 0; |     for (lfs2_size_t i = 0; | ||||||
|             i < ((cfg.block_count-2)/2)*(cfg.block_size-8); |             i < ((cfg.block_count-2)/2)*(cfg.block_size-8); | ||||||
|             i += size) { |             i += size) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion2", |     lfs2_file_open(&lfs2, &file, "exhaustion2", | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|     size = strlen("blahblahblahblah"); |     size = strlen("blahblahblahblah"); | ||||||
|     memcpy(buffer, "blahblahblahblah", size); |     memcpy(buffer, "blahblahblahblah", size); | ||||||
|     for (lfs2_size_t i = 0; |     for (lfs2_size_t i = 0; | ||||||
|             i < ((cfg.block_count-2+1)/2)*(cfg.block_size-8); |             i < ((cfg.block_count-2+1)/2)*(cfg.block_size-8); | ||||||
|             i += size) { |             i += size) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     // remount to force reset of lookahead |     // remount to force reset of lookahead | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     // rewrite one file with a hole of one block |     // rewrite one file with a hole of one block | ||||||
|     lfs2_file_open(&lfs2, &file[0], "exhaustion1", |     lfs2_file_open(&lfs2, &file, "exhaustion1", | ||||||
|             LFS2_O_WRONLY | LFS2_O_TRUNC) => 0; |             LFS2_O_WRONLY | LFS2_O_TRUNC) => 0; | ||||||
|     lfs2_file_sync(&lfs2, &file[0]) => 0; |     lfs2_file_sync(&lfs2, &file) => 0; | ||||||
|     size = strlen("blahblahblahblah"); |     size = strlen("blahblahblahblah"); | ||||||
|     memcpy(buffer, "blahblahblahblah", size); |     memcpy(buffer, "blahblahblahblah", size); | ||||||
|     for (lfs2_size_t i = 0; |     for (lfs2_size_t i = 0; | ||||||
|             i < ((cfg.block_count-2)/2 - 1)*(cfg.block_size-8); |             i < ((cfg.block_count-2)/2 - 1)*(cfg.block_size-8); | ||||||
|             i += size) { |             i += size) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     // try to allocate a directory, should fail! |     // try to allocate a directory, should fail! | ||||||
|     lfs2_mkdir(&lfs2, "split") => LFS2_ERR_NOSPC; |     lfs2_mkdir(&lfs2, "split") => LFS2_ERR_NOSPC; | ||||||
|  |  | ||||||
|     // file should not fail |     // file should not fail | ||||||
|     lfs2_file_open(&lfs2, &file[0], "notasplit", |     lfs2_file_open(&lfs2, &file, "notasplit", | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|     lfs2_file_write(&lfs2, &file[0], "hi", 2) => 2; |     lfs2_file_write(&lfs2, &file, "hi", 2) => 2; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Results ---" | scripts/results.py | ||||||
| tests/stats.py |  | ||||||
|   | |||||||
| @@ -1,24 +1,27 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| set -eu | set -eu | ||||||
|  | export TEST_FILE=$0 | ||||||
|  | trap 'export TEST_LINE=$LINENO' DEBUG | ||||||
|  |  | ||||||
| echo "=== Attr tests ===" | echo "=== Attr tests ===" | ||||||
| rm -rf blocks | rm -rf blocks | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "hello") => 0; |     lfs2_mkdir(&lfs2, "hello") => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "hello/hello", |     lfs2_file_open(&lfs2, &file, "hello/hello", | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|     lfs2_file_write(&lfs2, &file[0], "hello", strlen("hello")) |     lfs2_file_write(&lfs2, &file, "hello", strlen("hello")) | ||||||
|             => strlen("hello"); |             => strlen("hello"); | ||||||
|     lfs2_file_close(&lfs2, &file[0]); |     lfs2_file_close(&lfs2, &file); | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Set/get attribute ---" | echo "--- Set/get attribute ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |     memset(buffer, 0, sizeof(buffer)); | ||||||
|     lfs2_setattr(&lfs2, "hello", 'A', "aaaa",   4) => 0; |     lfs2_setattr(&lfs2, "hello", 'A', "aaaa",   4) => 0; | ||||||
|     lfs2_setattr(&lfs2, "hello", 'B', "bbbbbb", 6) => 0; |     lfs2_setattr(&lfs2, "hello", 'B', "bbbbbb", 6) => 0; | ||||||
|     lfs2_setattr(&lfs2, "hello", 'C', "ccccc",  5) => 0; |     lfs2_setattr(&lfs2, "hello", 'C', "ccccc",  5) => 0; | ||||||
| @@ -69,8 +72,9 @@ tests/test.py << TEST | |||||||
|  |  | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |     memset(buffer, 0, sizeof(buffer)); | ||||||
|     lfs2_getattr(&lfs2, "hello", 'A', buffer,    4) => 4; |     lfs2_getattr(&lfs2, "hello", 'A', buffer,    4) => 4; | ||||||
|     lfs2_getattr(&lfs2, "hello", 'B', buffer+4,  9) => 9; |     lfs2_getattr(&lfs2, "hello", 'B', buffer+4,  9) => 9; | ||||||
|     lfs2_getattr(&lfs2, "hello", 'C', buffer+13, 5) => 5; |     lfs2_getattr(&lfs2, "hello", 'C', buffer+13, 5) => 5; | ||||||
| @@ -78,16 +82,17 @@ tests/test.py << TEST | |||||||
|     memcmp(buffer+4,  "fffffffff", 9) => 0; |     memcmp(buffer+4,  "fffffffff", 9) => 0; | ||||||
|     memcmp(buffer+13, "ccccc",     5) => 0; |     memcmp(buffer+13, "ccccc",     5) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], "hello/hello", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &file, "hello/hello", LFS2_O_RDONLY) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, sizeof(buffer)) => strlen("hello"); |     lfs2_file_read(&lfs2, &file, buffer, sizeof(buffer)) => strlen("hello"); | ||||||
|     memcmp(buffer, "hello", strlen("hello")) => 0; |     memcmp(buffer, "hello", strlen("hello")) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]); |     lfs2_file_close(&lfs2, &file); | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Set/get root attribute ---" | echo "--- Set/get root attribute ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |     memset(buffer, 0, sizeof(buffer)); | ||||||
|     lfs2_setattr(&lfs2, "/", 'A', "aaaa",   4) => 0; |     lfs2_setattr(&lfs2, "/", 'A', "aaaa",   4) => 0; | ||||||
|     lfs2_setattr(&lfs2, "/", 'B', "bbbbbb", 6) => 0; |     lfs2_setattr(&lfs2, "/", 'B', "bbbbbb", 6) => 0; | ||||||
|     lfs2_setattr(&lfs2, "/", 'C', "ccccc",  5) => 0; |     lfs2_setattr(&lfs2, "/", 'C', "ccccc",  5) => 0; | ||||||
| @@ -137,8 +142,9 @@ tests/test.py << TEST | |||||||
|     lfs2_getattr(&lfs2, "/", 'C', buffer+10, 5) => 5; |     lfs2_getattr(&lfs2, "/", 'C', buffer+10, 5) => 5; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |     memset(buffer, 0, sizeof(buffer)); | ||||||
|     lfs2_getattr(&lfs2, "/", 'A', buffer,    4) => 4; |     lfs2_getattr(&lfs2, "/", 'A', buffer,    4) => 4; | ||||||
|     lfs2_getattr(&lfs2, "/", 'B', buffer+4,  9) => 9; |     lfs2_getattr(&lfs2, "/", 'B', buffer+4,  9) => 9; | ||||||
|     lfs2_getattr(&lfs2, "/", 'C', buffer+13, 5) => 5; |     lfs2_getattr(&lfs2, "/", 'C', buffer+13, 5) => 5; | ||||||
| @@ -146,16 +152,17 @@ tests/test.py << TEST | |||||||
|     memcmp(buffer+4,  "fffffffff", 9) => 0; |     memcmp(buffer+4,  "fffffffff", 9) => 0; | ||||||
|     memcmp(buffer+13, "ccccc",     5) => 0; |     memcmp(buffer+13, "ccccc",     5) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], "hello/hello", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &file, "hello/hello", LFS2_O_RDONLY) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, sizeof(buffer)) => strlen("hello"); |     lfs2_file_read(&lfs2, &file, buffer, sizeof(buffer)) => strlen("hello"); | ||||||
|     memcmp(buffer, "hello", strlen("hello")) => 0; |     memcmp(buffer, "hello", strlen("hello")) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]); |     lfs2_file_close(&lfs2, &file); | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Set/get file attribute ---" | echo "--- Set/get file attribute ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |     memset(buffer, 0, sizeof(buffer)); | ||||||
|     struct lfs2_attr attrs1[] = { |     struct lfs2_attr attrs1[] = { | ||||||
|         {'A', buffer,    4}, |         {'A', buffer,    4}, | ||||||
|         {'B', buffer+4,  6}, |         {'B', buffer+4,  6}, | ||||||
| @@ -163,55 +170,55 @@ tests/test.py << TEST | |||||||
|     }; |     }; | ||||||
|     struct lfs2_file_config cfg1 = {.attrs=attrs1, .attr_count=3}; |     struct lfs2_file_config cfg1 = {.attrs=attrs1, .attr_count=3}; | ||||||
|  |  | ||||||
|     lfs2_file_opencfg(&lfs2, &file[0], "hello/hello", LFS2_O_WRONLY, &cfg1) => 0; |     lfs2_file_opencfg(&lfs2, &file, "hello/hello", LFS2_O_WRONLY, &cfg1) => 0; | ||||||
|     memcpy(buffer,    "aaaa",   4); |     memcpy(buffer,    "aaaa",   4); | ||||||
|     memcpy(buffer+4,  "bbbbbb", 6); |     memcpy(buffer+4,  "bbbbbb", 6); | ||||||
|     memcpy(buffer+10, "ccccc",  5); |     memcpy(buffer+10, "ccccc",  5); | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     memset(buffer, 0, 15); |     memset(buffer, 0, 15); | ||||||
|     lfs2_file_opencfg(&lfs2, &file[0], "hello/hello", LFS2_O_RDONLY, &cfg1) => 0; |     lfs2_file_opencfg(&lfs2, &file, "hello/hello", LFS2_O_RDONLY, &cfg1) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     memcmp(buffer,    "aaaa",   4) => 0; |     memcmp(buffer,    "aaaa",   4) => 0; | ||||||
|     memcmp(buffer+4,  "bbbbbb", 6) => 0; |     memcmp(buffer+4,  "bbbbbb", 6) => 0; | ||||||
|     memcmp(buffer+10, "ccccc",  5) => 0; |     memcmp(buffer+10, "ccccc",  5) => 0; | ||||||
|  |  | ||||||
|     attrs1[1].size = 0; |     attrs1[1].size = 0; | ||||||
|     lfs2_file_opencfg(&lfs2, &file[0], "hello/hello", LFS2_O_WRONLY, &cfg1) => 0; |     lfs2_file_opencfg(&lfs2, &file, "hello/hello", LFS2_O_WRONLY, &cfg1) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     memset(buffer, 0, 15); |     memset(buffer, 0, 15); | ||||||
|     attrs1[1].size = 6; |     attrs1[1].size = 6; | ||||||
|     lfs2_file_opencfg(&lfs2, &file[0], "hello/hello", LFS2_O_RDONLY, &cfg1) => 0; |     lfs2_file_opencfg(&lfs2, &file, "hello/hello", LFS2_O_RDONLY, &cfg1) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     memcmp(buffer,    "aaaa",         4) => 0; |     memcmp(buffer,    "aaaa",         4) => 0; | ||||||
|     memcmp(buffer+4,  "\0\0\0\0\0\0", 6) => 0; |     memcmp(buffer+4,  "\0\0\0\0\0\0", 6) => 0; | ||||||
|     memcmp(buffer+10, "ccccc",        5) => 0; |     memcmp(buffer+10, "ccccc",        5) => 0; | ||||||
|  |  | ||||||
|     attrs1[1].size = 6; |     attrs1[1].size = 6; | ||||||
|     lfs2_file_opencfg(&lfs2, &file[0], "hello/hello", LFS2_O_WRONLY, &cfg1) => 0; |     lfs2_file_opencfg(&lfs2, &file, "hello/hello", LFS2_O_WRONLY, &cfg1) => 0; | ||||||
|     memcpy(buffer+4,  "dddddd", 6); |     memcpy(buffer+4,  "dddddd", 6); | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     memset(buffer, 0, 15); |     memset(buffer, 0, 15); | ||||||
|     attrs1[1].size = 6; |     attrs1[1].size = 6; | ||||||
|     lfs2_file_opencfg(&lfs2, &file[0], "hello/hello", LFS2_O_RDONLY, &cfg1) => 0; |     lfs2_file_opencfg(&lfs2, &file, "hello/hello", LFS2_O_RDONLY, &cfg1) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     memcmp(buffer,    "aaaa",   4) => 0; |     memcmp(buffer,    "aaaa",   4) => 0; | ||||||
|     memcmp(buffer+4,  "dddddd", 6) => 0; |     memcmp(buffer+4,  "dddddd", 6) => 0; | ||||||
|     memcmp(buffer+10, "ccccc",  5) => 0; |     memcmp(buffer+10, "ccccc",  5) => 0; | ||||||
|  |  | ||||||
|     attrs1[1].size = 3; |     attrs1[1].size = 3; | ||||||
|     lfs2_file_opencfg(&lfs2, &file[0], "hello/hello", LFS2_O_WRONLY, &cfg1) => 0; |     lfs2_file_opencfg(&lfs2, &file, "hello/hello", LFS2_O_WRONLY, &cfg1) => 0; | ||||||
|     memcpy(buffer+4,  "eee", 3); |     memcpy(buffer+4,  "eee", 3); | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     memset(buffer, 0, 15); |     memset(buffer, 0, 15); | ||||||
|     attrs1[1].size = 6; |     attrs1[1].size = 6; | ||||||
|     lfs2_file_opencfg(&lfs2, &file[0], "hello/hello", LFS2_O_RDONLY, &cfg1) => 0; |     lfs2_file_opencfg(&lfs2, &file, "hello/hello", LFS2_O_RDONLY, &cfg1) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     memcmp(buffer,    "aaaa",      4) => 0; |     memcmp(buffer,    "aaaa",      4) => 0; | ||||||
|     memcmp(buffer+4,  "eee\0\0\0", 6) => 0; |     memcmp(buffer+4,  "eee\0\0\0", 6) => 0; | ||||||
|     memcmp(buffer+10, "ccccc",     5) => 0; |     memcmp(buffer+10, "ccccc",     5) => 0; | ||||||
|  |  | ||||||
|     attrs1[0].size = LFS2_ATTR_MAX+1; |     attrs1[0].size = LFS2_ATTR_MAX+1; | ||||||
|     lfs2_file_opencfg(&lfs2, &file[0], "hello/hello", LFS2_O_WRONLY, &cfg1) |     lfs2_file_opencfg(&lfs2, &file, "hello/hello", LFS2_O_WRONLY, &cfg1) | ||||||
|         => LFS2_ERR_NOSPC; |         => LFS2_ERR_NOSPC; | ||||||
|  |  | ||||||
|     struct lfs2_attr attrs2[] = { |     struct lfs2_attr attrs2[] = { | ||||||
| @@ -220,17 +227,18 @@ tests/test.py << TEST | |||||||
|         {'C', buffer+13, 5}, |         {'C', buffer+13, 5}, | ||||||
|     }; |     }; | ||||||
|     struct lfs2_file_config cfg2 = {.attrs=attrs2, .attr_count=3}; |     struct lfs2_file_config cfg2 = {.attrs=attrs2, .attr_count=3}; | ||||||
|     lfs2_file_opencfg(&lfs2, &file[0], "hello/hello", LFS2_O_RDWR, &cfg2) => 0; |     lfs2_file_opencfg(&lfs2, &file, "hello/hello", LFS2_O_RDWR, &cfg2) => 0; | ||||||
|     memcpy(buffer+4,  "fffffffff", 9); |     memcpy(buffer+4,  "fffffffff", 9); | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     attrs1[0].size = 4; |     attrs1[0].size = 4; | ||||||
|     lfs2_file_opencfg(&lfs2, &file[0], "hello/hello", LFS2_O_RDONLY, &cfg1) => 0; |     lfs2_file_opencfg(&lfs2, &file, "hello/hello", LFS2_O_RDONLY, &cfg1) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |     memset(buffer, 0, sizeof(buffer)); | ||||||
|     struct lfs2_attr attrs2[] = { |     struct lfs2_attr attrs2[] = { | ||||||
|         {'A', buffer,    4}, |         {'A', buffer,    4}, | ||||||
|         {'B', buffer+4,  9}, |         {'B', buffer+4,  9}, | ||||||
| @@ -238,22 +246,23 @@ tests/test.py << TEST | |||||||
|     }; |     }; | ||||||
|     struct lfs2_file_config cfg2 = {.attrs=attrs2, .attr_count=3}; |     struct lfs2_file_config cfg2 = {.attrs=attrs2, .attr_count=3}; | ||||||
|  |  | ||||||
|     lfs2_file_opencfg(&lfs2, &file[0], "hello/hello", LFS2_O_RDONLY, &cfg2) => 0; |     lfs2_file_opencfg(&lfs2, &file, "hello/hello", LFS2_O_RDONLY, &cfg2) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     memcmp(buffer,    "aaaa",      4) => 0; |     memcmp(buffer,    "aaaa",      4) => 0; | ||||||
|     memcmp(buffer+4,  "fffffffff", 9) => 0; |     memcmp(buffer+4,  "fffffffff", 9) => 0; | ||||||
|     memcmp(buffer+13, "ccccc",     5) => 0; |     memcmp(buffer+13, "ccccc",     5) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], "hello/hello", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &file, "hello/hello", LFS2_O_RDONLY) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, sizeof(buffer)) => strlen("hello"); |     lfs2_file_read(&lfs2, &file, buffer, sizeof(buffer)) => strlen("hello"); | ||||||
|     memcmp(buffer, "hello", strlen("hello")) => 0; |     memcmp(buffer, "hello", strlen("hello")) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]); |     lfs2_file_close(&lfs2, &file); | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Deferred file attributes ---" | echo "--- Deferred file attributes ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |     memset(buffer, 0, sizeof(buffer)); | ||||||
|     struct lfs2_attr attrs1[] = { |     struct lfs2_attr attrs1[] = { | ||||||
|         {'B', "gggg", 4}, |         {'B', "gggg", 4}, | ||||||
|         {'C', "",     0}, |         {'C', "",     0}, | ||||||
| @@ -261,7 +270,7 @@ tests/test.py << TEST | |||||||
|     }; |     }; | ||||||
|     struct lfs2_file_config cfg1 = {.attrs=attrs1, .attr_count=3}; |     struct lfs2_file_config cfg1 = {.attrs=attrs1, .attr_count=3}; | ||||||
|  |  | ||||||
|     lfs2_file_opencfg(&lfs2, &file[0], "hello/hello", LFS2_O_WRONLY, &cfg1) => 0; |     lfs2_file_opencfg(&lfs2, &file, "hello/hello", LFS2_O_WRONLY, &cfg1) => 0; | ||||||
|  |  | ||||||
|     lfs2_getattr(&lfs2, "hello/hello", 'B', buffer,    9) => 9; |     lfs2_getattr(&lfs2, "hello/hello", 'B', buffer,    9) => 9; | ||||||
|     lfs2_getattr(&lfs2, "hello/hello", 'C', buffer+9,  9) => 5; |     lfs2_getattr(&lfs2, "hello/hello", 'C', buffer+9,  9) => 5; | ||||||
| @@ -270,7 +279,7 @@ tests/test.py << TEST | |||||||
|     memcmp(buffer+9,  "ccccc\0\0\0\0",      9) => 0; |     memcmp(buffer+9,  "ccccc\0\0\0\0",      9) => 0; | ||||||
|     memcmp(buffer+18, "\0\0\0\0\0\0\0\0\0", 9) => 0; |     memcmp(buffer+18, "\0\0\0\0\0\0\0\0\0", 9) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_sync(&lfs2, &file[0]) => 0; |     lfs2_file_sync(&lfs2, &file) => 0; | ||||||
|     lfs2_getattr(&lfs2, "hello/hello", 'B', buffer,    9) => 4; |     lfs2_getattr(&lfs2, "hello/hello", 'B', buffer,    9) => 4; | ||||||
|     lfs2_getattr(&lfs2, "hello/hello", 'C', buffer+9,  9) => 0; |     lfs2_getattr(&lfs2, "hello/hello", 'C', buffer+9,  9) => 0; | ||||||
|     lfs2_getattr(&lfs2, "hello/hello", 'D', buffer+18, 9) => 4; |     lfs2_getattr(&lfs2, "hello/hello", 'D', buffer+18, 9) => 4; | ||||||
| @@ -278,9 +287,8 @@ tests/test.py << TEST | |||||||
|     memcmp(buffer+9,  "\0\0\0\0\0\0\0\0\0", 9) => 0; |     memcmp(buffer+9,  "\0\0\0\0\0\0\0\0\0", 9) => 0; | ||||||
|     memcmp(buffer+18, "hhhh\0\0\0\0\0",     9) => 0; |     memcmp(buffer+18, "hhhh\0\0\0\0\0",     9) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Results ---" | scripts/results.py | ||||||
| tests/stats.py |  | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| set -eu | set -eu | ||||||
|  | export TEST_FILE=$0 | ||||||
|  | trap 'export TEST_LINE=$LINENO' DEBUG | ||||||
|  |  | ||||||
| echo "=== Corrupt tests ===" | echo "=== Corrupt tests ===" | ||||||
|  |  | ||||||
| @@ -7,7 +9,7 @@ NAMEMULT=64 | |||||||
| FILEMULT=1 | FILEMULT=1 | ||||||
|  |  | ||||||
| lfs2_mktree() { | lfs2_mktree() { | ||||||
| tests/test.py ${1:-} << TEST | scripts/test.py ${1:-} << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
| @@ -23,22 +25,22 @@ tests/test.py ${1:-} << TEST | |||||||
|             buffer[j+$NAMEMULT+1] = '0'+i; |             buffer[j+$NAMEMULT+1] = '0'+i; | ||||||
|         } |         } | ||||||
|         buffer[2*$NAMEMULT+1] = '\0'; |         buffer[2*$NAMEMULT+1] = '\0'; | ||||||
|         lfs2_file_open(&lfs2, &file[0], (char*)buffer, |         lfs2_file_open(&lfs2, &file, (char*)buffer, | ||||||
|                 LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |                 LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|          |          | ||||||
|         size = $NAMEMULT; |         lfs2_size_t size = $NAMEMULT; | ||||||
|         for (int j = 0; j < i*$FILEMULT; j++) { |         for (int j = 0; j < i*$FILEMULT; j++) { | ||||||
|             lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |             lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         lfs2_file_close(&lfs2, &file[0]) => 0; |         lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     } |     } | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| } | } | ||||||
|  |  | ||||||
| lfs2_chktree() { | lfs2_chktree() { | ||||||
| tests/test.py ${1:-} << TEST | scripts/test.py ${1:-} << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     for (int i = 1; i < 10; i++) { |     for (int i = 1; i < 10; i++) { | ||||||
|         for (int j = 0; j < $NAMEMULT; j++) { |         for (int j = 0; j < $NAMEMULT; j++) { | ||||||
| @@ -53,15 +55,16 @@ tests/test.py ${1:-} << TEST | |||||||
|             buffer[j+$NAMEMULT+1] = '0'+i; |             buffer[j+$NAMEMULT+1] = '0'+i; | ||||||
|         } |         } | ||||||
|         buffer[2*$NAMEMULT+1] = '\0'; |         buffer[2*$NAMEMULT+1] = '\0'; | ||||||
|         lfs2_file_open(&lfs2, &file[0], (char*)buffer, LFS2_O_RDONLY) => 0; |         lfs2_file_open(&lfs2, &file, (char*)buffer, LFS2_O_RDONLY) => 0; | ||||||
|          |          | ||||||
|         size = $NAMEMULT; |         lfs2_size_t size = $NAMEMULT; | ||||||
|         for (int j = 0; j < i*$FILEMULT; j++) { |         for (int j = 0; j < i*$FILEMULT; j++) { | ||||||
|             lfs2_file_read(&lfs2, &file[0], rbuffer, size) => size; |             uint8_t rbuffer[1024]; | ||||||
|  |             lfs2_file_read(&lfs2, &file, rbuffer, size) => size; | ||||||
|             memcmp(buffer, rbuffer, size) => 0; |             memcmp(buffer, rbuffer, size) => 0; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         lfs2_file_close(&lfs2, &file[0]) => 0; |         lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     } |     } | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| @@ -114,5 +117,4 @@ done | |||||||
| lfs2_mktree | lfs2_mktree | ||||||
| lfs2_chktree | lfs2_chktree | ||||||
|  |  | ||||||
| echo "--- Results ---" | scripts/results.py | ||||||
| tests/stats.py |  | ||||||
|   | |||||||
| @@ -1,188 +1,191 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| set -eu | set -eu | ||||||
|  | export TEST_FILE=$0 | ||||||
|  | trap 'export TEST_LINE=$LINENO' DEBUG | ||||||
|  |  | ||||||
|  | echo "=== Directory tests ===" | ||||||
|  |  | ||||||
| LARGESIZE=128 | LARGESIZE=128 | ||||||
|  |  | ||||||
| echo "=== Directory tests ===" |  | ||||||
| rm -rf blocks | rm -rf blocks | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Root directory ---" | echo "--- Root directory ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "/") => 0; |     lfs2_dir_open(&lfs2, &dir, "/") => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Directory creation ---" | echo "--- Directory creation ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "potato") => 0; |     lfs2_mkdir(&lfs2, "potato") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- File creation ---" | echo "--- File creation ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "burito", LFS2_O_CREAT | LFS2_O_WRONLY) => 0; |     lfs2_file_open(&lfs2, &file, "burito", LFS2_O_CREAT | LFS2_O_WRONLY) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Directory iteration ---" | echo "--- Directory iteration ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "/") => 0; |     lfs2_dir_open(&lfs2, &dir, "/") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "burito") => 0; |     strcmp(info.name, "burito") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "potato") => 0; |     strcmp(info.name, "potato") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Directory failures ---" | echo "--- Directory failures ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "potato") => LFS2_ERR_EXIST; |     lfs2_mkdir(&lfs2, "potato") => LFS2_ERR_EXIST; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "tomato") => LFS2_ERR_NOENT; |     lfs2_dir_open(&lfs2, &dir, "tomato") => LFS2_ERR_NOENT; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "burito") => LFS2_ERR_NOTDIR; |     lfs2_dir_open(&lfs2, &dir, "burito") => LFS2_ERR_NOTDIR; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "tomato", LFS2_O_RDONLY) => LFS2_ERR_NOENT; |     lfs2_file_open(&lfs2, &file, "tomato", LFS2_O_RDONLY) => LFS2_ERR_NOENT; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "potato", LFS2_O_RDONLY) => LFS2_ERR_ISDIR; |     lfs2_file_open(&lfs2, &file, "potato", LFS2_O_RDONLY) => LFS2_ERR_ISDIR; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Nested directories ---" | echo "--- Nested directories ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "potato/baked") => 0; |     lfs2_mkdir(&lfs2, "potato/baked") => 0; | ||||||
|     lfs2_mkdir(&lfs2, "potato/sweet") => 0; |     lfs2_mkdir(&lfs2, "potato/sweet") => 0; | ||||||
|     lfs2_mkdir(&lfs2, "potato/fried") => 0; |     lfs2_mkdir(&lfs2, "potato/fried") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "potato") => 0; |     lfs2_dir_open(&lfs2, &dir, "potato") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "baked") => 0; |     strcmp(info.name, "baked") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "fried") => 0; |     strcmp(info.name, "fried") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "sweet") => 0; |     strcmp(info.name, "sweet") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Multi-block directory ---" | echo "--- Multi-block directory ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "cactus") => 0; |     lfs2_mkdir(&lfs2, "cactus") => 0; | ||||||
|     for (int i = 0; i < $LARGESIZE; i++) { |     for (int i = 0; i < $LARGESIZE; i++) { | ||||||
|         sprintf((char*)buffer, "cactus/test%03d", i); |         sprintf(path, "cactus/test%03d", i); | ||||||
|         lfs2_mkdir(&lfs2, (char*)buffer) => 0; |         lfs2_mkdir(&lfs2, path) => 0; | ||||||
|     } |     } | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "cactus") => 0; |     lfs2_dir_open(&lfs2, &dir, "cactus") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     for (int i = 0; i < $LARGESIZE; i++) { |     for (int i = 0; i < $LARGESIZE; i++) { | ||||||
|         sprintf((char*)buffer, "test%03d", i); |         sprintf(path, "test%03d", i); | ||||||
|         lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |         lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|         strcmp(info.name, (char*)buffer) => 0; |         strcmp(info.name, path) => 0; | ||||||
|         info.type => LFS2_TYPE_DIR; |         info.type => LFS2_TYPE_DIR; | ||||||
|     } |     } | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Directory remove ---" | echo "--- Directory remove ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_remove(&lfs2, "potato") => LFS2_ERR_NOTEMPTY; |     lfs2_remove(&lfs2, "potato") => LFS2_ERR_NOTEMPTY; | ||||||
|     lfs2_remove(&lfs2, "potato/sweet") => 0; |     lfs2_remove(&lfs2, "potato/sweet") => 0; | ||||||
|     lfs2_remove(&lfs2, "potato/baked") => 0; |     lfs2_remove(&lfs2, "potato/baked") => 0; | ||||||
|     lfs2_remove(&lfs2, "potato/fried") => 0; |     lfs2_remove(&lfs2, "potato/fried") => 0; | ||||||
|  |  | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "potato") => 0; |     lfs2_dir_open(&lfs2, &dir, "potato") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|  |  | ||||||
|     lfs2_remove(&lfs2, "potato") => 0; |     lfs2_remove(&lfs2, "potato") => 0; | ||||||
|  |  | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "/") => 0; |     lfs2_dir_open(&lfs2, &dir, "/") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "burito") => 0; |     strcmp(info.name, "burito") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "cactus") => 0; |     strcmp(info.name, "cactus") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "/") => 0; |     lfs2_dir_open(&lfs2, &dir, "/") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "burito") => 0; |     strcmp(info.name, "burito") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "cactus") => 0; |     strcmp(info.name, "cactus") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Directory rename ---" | echo "--- Directory rename ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "coldpotato") => 0; |     lfs2_mkdir(&lfs2, "coldpotato") => 0; | ||||||
|     lfs2_mkdir(&lfs2, "coldpotato/baked") => 0; |     lfs2_mkdir(&lfs2, "coldpotato/baked") => 0; | ||||||
| @@ -190,34 +193,34 @@ tests/test.py << TEST | |||||||
|     lfs2_mkdir(&lfs2, "coldpotato/fried") => 0; |     lfs2_mkdir(&lfs2, "coldpotato/fried") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_rename(&lfs2, "coldpotato", "hotpotato") => 0; |     lfs2_rename(&lfs2, "coldpotato", "hotpotato") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "hotpotato") => 0; |     lfs2_dir_open(&lfs2, &dir, "hotpotato") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "baked") => 0; |     strcmp(info.name, "baked") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "fried") => 0; |     strcmp(info.name, "fried") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "sweet") => 0; |     strcmp(info.name, "sweet") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "warmpotato") => 0; |     lfs2_mkdir(&lfs2, "warmpotato") => 0; | ||||||
|     lfs2_mkdir(&lfs2, "warmpotato/mushy") => 0; |     lfs2_mkdir(&lfs2, "warmpotato/mushy") => 0; | ||||||
| @@ -228,29 +231,29 @@ tests/test.py << TEST | |||||||
|  |  | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "warmpotato") => 0; |     lfs2_dir_open(&lfs2, &dir, "warmpotato") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "baked") => 0; |     strcmp(info.name, "baked") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "fried") => 0; |     strcmp(info.name, "fried") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "sweet") => 0; |     strcmp(info.name, "sweet") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "coldpotato") => 0; |     lfs2_mkdir(&lfs2, "coldpotato") => 0; | ||||||
|     lfs2_rename(&lfs2, "warmpotato/baked", "coldpotato/baked") => 0; |     lfs2_rename(&lfs2, "warmpotato/baked", "coldpotato/baked") => 0; | ||||||
| @@ -260,225 +263,227 @@ tests/test.py << TEST | |||||||
|     lfs2_remove(&lfs2, "warmpotato") => 0; |     lfs2_remove(&lfs2, "warmpotato") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "coldpotato") => 0; |     lfs2_dir_open(&lfs2, &dir, "coldpotato") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "baked") => 0; |     strcmp(info.name, "baked") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "fried") => 0; |     strcmp(info.name, "fried") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "sweet") => 0; |     strcmp(info.name, "sweet") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Recursive remove ---" | echo "--- Recursive remove ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_remove(&lfs2, "coldpotato") => LFS2_ERR_NOTEMPTY; |     lfs2_remove(&lfs2, "coldpotato") => LFS2_ERR_NOTEMPTY; | ||||||
|  |  | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "coldpotato") => 0; |     lfs2_dir_open(&lfs2, &dir, "coldpotato") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|  |  | ||||||
|     while (true) { |     while (true) { | ||||||
|         int err = lfs2_dir_read(&lfs2, &dir[0], &info); |         int err = lfs2_dir_read(&lfs2, &dir, &info); | ||||||
|         err >= 0 => 1; |         err >= 0 => 1; | ||||||
|         if (err == 0) { |         if (err == 0) { | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         strcpy((char*)buffer, "coldpotato/"); |         strcpy(path, "coldpotato/"); | ||||||
|         strcat((char*)buffer, info.name); |         strcat(path, info.name); | ||||||
|         lfs2_remove(&lfs2, (char*)buffer) => 0; |         lfs2_remove(&lfs2, path) => 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_remove(&lfs2, "coldpotato") => 0; |     lfs2_remove(&lfs2, "coldpotato") => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "/") => 0; |     lfs2_dir_open(&lfs2, &dir, "/") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "burito") => 0; |     strcmp(info.name, "burito") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "cactus") => 0; |     strcmp(info.name, "cactus") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Multi-block rename ---" | echo "--- Multi-block rename ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     for (int i = 0; i < $LARGESIZE; i++) { |     for (int i = 0; i < $LARGESIZE; i++) { | ||||||
|         sprintf((char*)buffer, "cactus/test%03d", i); |         char oldpath[1024]; | ||||||
|         sprintf((char*)wbuffer, "cactus/tedd%03d", i); |         char newpath[1024]; | ||||||
|         lfs2_rename(&lfs2, (char*)buffer, (char*)wbuffer) => 0; |         sprintf(oldpath, "cactus/test%03d", i); | ||||||
|  |         sprintf(newpath, "cactus/tedd%03d", i); | ||||||
|  |         lfs2_rename(&lfs2, oldpath, newpath) => 0; | ||||||
|     } |     } | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "cactus") => 0; |     lfs2_dir_open(&lfs2, &dir, "cactus") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     for (int i = 0; i < $LARGESIZE; i++) { |     for (int i = 0; i < $LARGESIZE; i++) { | ||||||
|         sprintf((char*)buffer, "tedd%03d", i); |         sprintf(path, "tedd%03d", i); | ||||||
|         lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |         lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|         strcmp(info.name, (char*)buffer) => 0; |         strcmp(info.name, path) => 0; | ||||||
|         info.type => LFS2_TYPE_DIR; |         info.type => LFS2_TYPE_DIR; | ||||||
|     } |     } | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Multi-block remove ---" | echo "--- Multi-block remove ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_remove(&lfs2, "cactus") => LFS2_ERR_NOTEMPTY; |     lfs2_remove(&lfs2, "cactus") => LFS2_ERR_NOTEMPTY; | ||||||
|  |  | ||||||
|     for (int i = 0; i < $LARGESIZE; i++) { |     for (int i = 0; i < $LARGESIZE; i++) { | ||||||
|         sprintf((char*)buffer, "cactus/tedd%03d", i); |         sprintf(path, "cactus/tedd%03d", i); | ||||||
|         lfs2_remove(&lfs2, (char*)buffer) => 0; |         lfs2_remove(&lfs2, path) => 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_remove(&lfs2, "cactus") => 0; |     lfs2_remove(&lfs2, "cactus") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "/") => 0; |     lfs2_dir_open(&lfs2, &dir, "/") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "burito") => 0; |     strcmp(info.name, "burito") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Multi-block directory with files ---" | echo "--- Multi-block directory with files ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "prickly-pear") => 0; |     lfs2_mkdir(&lfs2, "prickly-pear") => 0; | ||||||
|     for (int i = 0; i < $LARGESIZE; i++) { |     for (int i = 0; i < $LARGESIZE; i++) { | ||||||
|         sprintf((char*)buffer, "prickly-pear/test%03d", i); |         sprintf(path, "prickly-pear/test%03d", i); | ||||||
|         lfs2_file_open(&lfs2, &file[0], (char*)buffer, |         lfs2_file_open(&lfs2, &file, path, LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|                 LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |         lfs2_size_t size = 6; | ||||||
|         size = 6; |         memcpy(buffer, "Hello", size); | ||||||
|         memcpy(wbuffer, "Hello", size); |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|         lfs2_file_write(&lfs2, &file[0], wbuffer, size) => size; |         lfs2_file_close(&lfs2, &file) => 0; | ||||||
|         lfs2_file_close(&lfs2, &file[0]) => 0; |  | ||||||
|     } |     } | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "prickly-pear") => 0; |     lfs2_dir_open(&lfs2, &dir, "prickly-pear") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     for (int i = 0; i < $LARGESIZE; i++) { |     for (int i = 0; i < $LARGESIZE; i++) { | ||||||
|         sprintf((char*)buffer, "test%03d", i); |         sprintf(path, "test%03d", i); | ||||||
|         lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |         lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|         strcmp(info.name, (char*)buffer) => 0; |         strcmp(info.name, path) => 0; | ||||||
|         info.type => LFS2_TYPE_REG; |         info.type => LFS2_TYPE_REG; | ||||||
|         info.size => 6; |         info.size => 6; | ||||||
|     } |     } | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Multi-block rename with files ---" | echo "--- Multi-block rename with files ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     for (int i = 0; i < $LARGESIZE; i++) { |     for (int i = 0; i < $LARGESIZE; i++) { | ||||||
|         sprintf((char*)buffer, "prickly-pear/test%03d", i); |         char oldpath[1024]; | ||||||
|         sprintf((char*)wbuffer, "prickly-pear/tedd%03d", i); |         char newpath[1024]; | ||||||
|         lfs2_rename(&lfs2, (char*)buffer, (char*)wbuffer) => 0; |         sprintf(oldpath, "prickly-pear/test%03d", i); | ||||||
|  |         sprintf(newpath, "prickly-pear/tedd%03d", i); | ||||||
|  |         lfs2_rename(&lfs2, oldpath, newpath) => 0; | ||||||
|     } |     } | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "prickly-pear") => 0; |     lfs2_dir_open(&lfs2, &dir, "prickly-pear") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     for (int i = 0; i < $LARGESIZE; i++) { |     for (int i = 0; i < $LARGESIZE; i++) { | ||||||
|         sprintf((char*)buffer, "tedd%03d", i); |         sprintf(path, "tedd%03d", i); | ||||||
|         lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |         lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|         strcmp(info.name, (char*)buffer) => 0; |         strcmp(info.name, path) => 0; | ||||||
|         info.type => LFS2_TYPE_REG; |         info.type => LFS2_TYPE_REG; | ||||||
|         info.size => 6; |         info.size => 6; | ||||||
|     } |     } | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Multi-block remove with files ---" | echo "--- Multi-block remove with files ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_remove(&lfs2, "prickly-pear") => LFS2_ERR_NOTEMPTY; |     lfs2_remove(&lfs2, "prickly-pear") => LFS2_ERR_NOTEMPTY; | ||||||
|  |  | ||||||
|     for (int i = 0; i < $LARGESIZE; i++) { |     for (int i = 0; i < $LARGESIZE; i++) { | ||||||
|         sprintf((char*)buffer, "prickly-pear/tedd%03d", i); |         sprintf(path, "prickly-pear/tedd%03d", i); | ||||||
|         lfs2_remove(&lfs2, (char*)buffer) => 0; |         lfs2_remove(&lfs2, path) => 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_remove(&lfs2, "prickly-pear") => 0; |     lfs2_remove(&lfs2, "prickly-pear") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "/") => 0; |     lfs2_dir_open(&lfs2, &dir, "/") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "burito") => 0; |     strcmp(info.name, "burito") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Results ---" | scripts/results.py | ||||||
| tests/stats.py |  | ||||||
|   | |||||||
| @@ -1,19 +1,22 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| set -eu | set -eu | ||||||
|  | export TEST_FILE=$0 | ||||||
|  | trap 'export TEST_LINE=$LINENO' DEBUG | ||||||
|  |  | ||||||
|  | echo "=== Entry tests ===" | ||||||
|  |  | ||||||
| # Note: These tests are intended for 512 byte inline size at different | # Note: These tests are intended for 512 byte inline size at different | ||||||
| # inline sizes they should still pass, but won't be testing anything | # inline sizes they should still pass, but won't be testing anything | ||||||
|  |  | ||||||
| echo "=== Entry tests ===" |  | ||||||
| rm -rf blocks | rm -rf blocks | ||||||
| function read_file { | function read_file { | ||||||
| cat << TEST | cat << TEST | ||||||
|  |  | ||||||
|     size = $2; |     size = $2; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "$1", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &file, "$1", LFS2_O_RDONLY) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], rbuffer, size) => size; |     lfs2_file_read(&lfs2, &file, rbuffer, size) => size; | ||||||
|     memcmp(rbuffer, wbuffer, size) => 0; |     memcmp(rbuffer, wbuffer, size) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
| TEST | TEST | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -21,18 +24,22 @@ function write_file { | |||||||
| cat << TEST | cat << TEST | ||||||
|  |  | ||||||
|     size = $2; |     size = $2; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "$1", |     lfs2_file_open(&lfs2, &file, "$1", | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_TRUNC) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_TRUNC) => 0; | ||||||
|     memset(wbuffer, 'c', size); |     memset(wbuffer, 'c', size); | ||||||
|     lfs2_file_write(&lfs2, &file[0], wbuffer, size) => size; |     lfs2_file_write(&lfs2, &file, wbuffer, size) => size; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
| TEST | TEST | ||||||
| } | } | ||||||
|  |  | ||||||
| echo "--- Entry grow test ---" | echo "--- Entry grow test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|  |     uint8_t wbuffer[1024]; | ||||||
|  |     uint8_t rbuffer[1024]; | ||||||
|  |     lfs2_size_t size; | ||||||
|  |  | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     $(write_file "hi0" 20) |     $(write_file "hi0" 20) | ||||||
|     $(write_file "hi1" 20) |     $(write_file "hi1" 20) | ||||||
| @@ -50,9 +57,13 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Entry shrink test ---" | echo "--- Entry shrink test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|  |     uint8_t wbuffer[1024]; | ||||||
|  |     uint8_t rbuffer[1024]; | ||||||
|  |     lfs2_size_t size; | ||||||
|  |  | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     $(write_file "hi0" 20) |     $(write_file "hi0" 20) | ||||||
|     $(write_file "hi1" 200) |     $(write_file "hi1" 200) | ||||||
| @@ -70,9 +81,13 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Entry spill test ---" | echo "--- Entry spill test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|  |     uint8_t wbuffer[1024]; | ||||||
|  |     uint8_t rbuffer[1024]; | ||||||
|  |     lfs2_size_t size; | ||||||
|  |  | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     $(write_file "hi0" 200) |     $(write_file "hi0" 200) | ||||||
|     $(write_file "hi1" 200) |     $(write_file "hi1" 200) | ||||||
| @@ -87,9 +102,13 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Entry push spill test ---" | echo "--- Entry push spill test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|  |     uint8_t wbuffer[1024]; | ||||||
|  |     uint8_t rbuffer[1024]; | ||||||
|  |     lfs2_size_t size; | ||||||
|  |  | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     $(write_file "hi0" 200) |     $(write_file "hi0" 200) | ||||||
|     $(write_file "hi1" 20) |     $(write_file "hi1" 20) | ||||||
| @@ -107,9 +126,13 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Entry push spill two test ---" | echo "--- Entry push spill two test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|  |     uint8_t wbuffer[1024]; | ||||||
|  |     uint8_t rbuffer[1024]; | ||||||
|  |     lfs2_size_t size; | ||||||
|  |  | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     $(write_file "hi0" 200) |     $(write_file "hi0" 200) | ||||||
|     $(write_file "hi1" 20) |     $(write_file "hi1" 20) | ||||||
| @@ -129,9 +152,13 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Entry drop test ---" | echo "--- Entry drop test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|  |     uint8_t wbuffer[1024]; | ||||||
|  |     uint8_t rbuffer[1024]; | ||||||
|  |     lfs2_size_t size; | ||||||
|  |  | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     $(write_file "hi0" 200) |     $(write_file "hi0" 200) | ||||||
|     $(write_file "hi1" 200) |     $(write_file "hi1" 200) | ||||||
| @@ -159,63 +186,66 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Create too big ---" | echo "--- Create too big ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     memset(buffer, 'm', 200); |     memset(path, 'm', 200); | ||||||
|     buffer[200] = '\0'; |     path[200] = '\0'; | ||||||
|  |  | ||||||
|     size = 400; |     lfs2_size_t size = 400; | ||||||
|     lfs2_file_open(&lfs2, &file[0], (char*)buffer, |     lfs2_file_open(&lfs2, &file, path, | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_TRUNC) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_TRUNC) => 0; | ||||||
|  |     uint8_t wbuffer[1024]; | ||||||
|     memset(wbuffer, 'c', size); |     memset(wbuffer, 'c', size); | ||||||
|     lfs2_file_write(&lfs2, &file[0], wbuffer, size) => size; |     lfs2_file_write(&lfs2, &file, wbuffer, size) => size; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     size = 400; |     size = 400; | ||||||
|     lfs2_file_open(&lfs2, &file[0], (char*)buffer, LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &file, path, LFS2_O_RDONLY) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], rbuffer, size) => size; |     uint8_t rbuffer[1024]; | ||||||
|  |     lfs2_file_read(&lfs2, &file, rbuffer, size) => size; | ||||||
|     memcmp(rbuffer, wbuffer, size) => 0; |     memcmp(rbuffer, wbuffer, size) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Resize too big ---" | echo "--- Resize too big ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     memset(buffer, 'm', 200); |     memset(path, 'm', 200); | ||||||
|     buffer[200] = '\0'; |     path[200] = '\0'; | ||||||
|  |  | ||||||
|  |     lfs2_size_t size = 40; | ||||||
|  |     lfs2_file_open(&lfs2, &file, path, | ||||||
|  |             LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_TRUNC) => 0; | ||||||
|  |     uint8_t wbuffer[1024]; | ||||||
|  |     memset(wbuffer, 'c', size); | ||||||
|  |     lfs2_file_write(&lfs2, &file, wbuffer, size) => size; | ||||||
|  |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     size = 40; |     size = 40; | ||||||
|     lfs2_file_open(&lfs2, &file[0], (char*)buffer, |     lfs2_file_open(&lfs2, &file, path, LFS2_O_RDONLY) => 0; | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_TRUNC) => 0; |     uint8_t rbuffer[1024]; | ||||||
|     memset(wbuffer, 'c', size); |     lfs2_file_read(&lfs2, &file, rbuffer, size) => size; | ||||||
|     lfs2_file_write(&lfs2, &file[0], wbuffer, size) => size; |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |  | ||||||
|  |  | ||||||
|     size = 40; |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], (char*)buffer, LFS2_O_RDONLY) => 0; |  | ||||||
|     lfs2_file_read(&lfs2, &file[0], rbuffer, size) => size; |  | ||||||
|     memcmp(rbuffer, wbuffer, size) => 0; |     memcmp(rbuffer, wbuffer, size) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     size = 400; |     size = 400; | ||||||
|     lfs2_file_open(&lfs2, &file[0], (char*)buffer, |     lfs2_file_open(&lfs2, &file, path, | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_TRUNC) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_TRUNC) => 0; | ||||||
|     memset(wbuffer, 'c', size); |     memset(wbuffer, 'c', size); | ||||||
|     lfs2_file_write(&lfs2, &file[0], wbuffer, size) => size; |     lfs2_file_write(&lfs2, &file, wbuffer, size) => size; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     size = 400; |     size = 400; | ||||||
|     lfs2_file_open(&lfs2, &file[0], (char*)buffer, LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &file, path, LFS2_O_RDONLY) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], rbuffer, size) => size; |     lfs2_file_read(&lfs2, &file, rbuffer, size) => size; | ||||||
|     memcmp(rbuffer, wbuffer, size) => 0; |     memcmp(rbuffer, wbuffer, size) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Results ---" | scripts/results.py | ||||||
| tests/stats.py |  | ||||||
|   | |||||||
| @@ -1,71 +1,76 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| set -eu | set -eu | ||||||
|  | export TEST_FILE=$0 | ||||||
|  | trap 'export TEST_LINE=$LINENO' DEBUG | ||||||
|  |  | ||||||
|  | echo "=== File tests ===" | ||||||
|  |  | ||||||
| SMALLSIZE=32 | SMALLSIZE=32 | ||||||
| MEDIUMSIZE=8192 | MEDIUMSIZE=8192 | ||||||
| LARGESIZE=262144 | LARGESIZE=262144 | ||||||
|  |  | ||||||
| echo "=== File tests ===" |  | ||||||
| rm -rf blocks | rm -rf blocks | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Simple file test ---" | echo "--- Simple file test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "hello", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |     lfs2_file_open(&lfs2, &file, "hello", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|     size = strlen("Hello World!\n"); |     lfs2_size_t size = strlen("Hello World!\n"); | ||||||
|  |     uint8_t wbuffer[1024]; | ||||||
|     memcpy(wbuffer, "Hello World!\n", size); |     memcpy(wbuffer, "Hello World!\n", size); | ||||||
|     lfs2_file_write(&lfs2, &file[0], wbuffer, size) => size; |     lfs2_file_write(&lfs2, &file, wbuffer, size) => size; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], "hello", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &file, "hello", LFS2_O_RDONLY) => 0; | ||||||
|     size = strlen("Hello World!\n"); |     size = strlen("Hello World!\n"); | ||||||
|     lfs2_file_read(&lfs2, &file[0], rbuffer, size) => size; |     uint8_t rbuffer[1024]; | ||||||
|  |     lfs2_file_read(&lfs2, &file, rbuffer, size) => size; | ||||||
|     memcmp(rbuffer, wbuffer, size) => 0; |     memcmp(rbuffer, wbuffer, size) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| w_test() { | w_test() { | ||||||
| tests/test.py ${4:-} << TEST | scripts/test.py ${4:-} << TEST | ||||||
|     size = $1; |     lfs2_size_t size = $1; | ||||||
|     lfs2_size_t chunk = 31; |     lfs2_size_t chunk = 31; | ||||||
|     srand(0); |     srand(0); | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "$2", |     lfs2_file_open(&lfs2, &file, "$2", | ||||||
|         ${3:-LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_TRUNC}) => 0; |         ${3:-LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_TRUNC}) => 0; | ||||||
|     for (lfs2_size_t i = 0; i < size; i += chunk) { |     for (lfs2_size_t i = 0; i < size; i += chunk) { | ||||||
|         chunk = (chunk < size - i) ? chunk : size - i; |         chunk = (chunk < size - i) ? chunk : size - i; | ||||||
|         for (lfs2_size_t b = 0; b < chunk; b++) { |         for (lfs2_size_t b = 0; b < chunk; b++) { | ||||||
|             buffer[b] = rand() & 0xff; |             buffer[b] = rand() & 0xff; | ||||||
|         } |         } | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, chunk) => chunk; |         lfs2_file_write(&lfs2, &file, buffer, chunk) => chunk; | ||||||
|     } |     } | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| } | } | ||||||
|  |  | ||||||
| r_test() { | r_test() { | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     size = $1; |     lfs2_size_t size = $1; | ||||||
|     lfs2_size_t chunk = 29; |     lfs2_size_t chunk = 29; | ||||||
|     srand(0); |     srand(0); | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_stat(&lfs2, "$2", &info) => 0; |     lfs2_stat(&lfs2, "$2", &info) => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     info.size => size; |     info.size => size; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "$2", ${3:-LFS2_O_RDONLY}) => 0; |     lfs2_file_open(&lfs2, &file, "$2", ${3:-LFS2_O_RDONLY}) => 0; | ||||||
|     for (lfs2_size_t i = 0; i < size; i += chunk) { |     for (lfs2_size_t i = 0; i < size; i += chunk) { | ||||||
|         chunk = (chunk < size - i) ? chunk : size - i; |         chunk = (chunk < size - i) ? chunk : size - i; | ||||||
|         lfs2_file_read(&lfs2, &file[0], buffer, chunk) => chunk; |         lfs2_file_read(&lfs2, &file, buffer, chunk) => chunk; | ||||||
|         for (lfs2_size_t b = 0; b < chunk && i+b < size; b++) { |         for (lfs2_size_t b = 0; b < chunk && i+b < size; b++) { | ||||||
|             buffer[b] => rand() & 0xff; |             buffer[b] => rand() & 0xff; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| } | } | ||||||
| @@ -105,54 +110,112 @@ r_test $LARGESIZE largeavacado | |||||||
| r_test 0 noavacado | r_test 0 noavacado | ||||||
|  |  | ||||||
| echo "--- Dir check ---" | echo "--- Dir check ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "/") => 0; |     lfs2_dir_open(&lfs2, &dir, "/") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "hello") => 0; |     strcmp(info.name, "hello") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     info.size => strlen("Hello World!\n"); |     info.size => strlen("Hello World!\n"); | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "largeavacado") => 0; |     strcmp(info.name, "largeavacado") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     info.size => $LARGESIZE; |     info.size => $LARGESIZE; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "mediumavacado") => 0; |     strcmp(info.name, "mediumavacado") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     info.size => $MEDIUMSIZE; |     info.size => $MEDIUMSIZE; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "noavacado") => 0; |     strcmp(info.name, "noavacado") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     info.size => 0; |     info.size => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "smallavacado") => 0; |     strcmp(info.name, "smallavacado") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     info.size => $SMALLSIZE; |     info.size => $SMALLSIZE; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Many file test ---" | echo "--- Many files test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     // Create 300 files of 6 bytes |     // Create 300 files of 7 bytes | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "directory") => 0; |  | ||||||
|     for (unsigned i = 0; i < 300; i++) { |     for (unsigned i = 0; i < 300; i++) { | ||||||
|         snprintf((char*)buffer, sizeof(buffer), "file_%03d", i); |         sprintf(path, "file_%03d", i); | ||||||
|         lfs2_file_open(&lfs2, &file[0], (char*)buffer, LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |         lfs2_file_open(&lfs2, &file, path, | ||||||
|         size = 6; |                 LFS2_O_RDWR | LFS2_O_CREAT | LFS2_O_EXCL) => 0; | ||||||
|         memcpy(wbuffer, "Hello", size); |         lfs2_size_t size = 7; | ||||||
|         lfs2_file_write(&lfs2, &file[0], wbuffer, size) => size; |         uint8_t wbuffer[1024]; | ||||||
|         lfs2_file_close(&lfs2, &file[0]) => 0; |         uint8_t rbuffer[1024]; | ||||||
|  |         snprintf((char*)wbuffer, size, "Hi %03d", i); | ||||||
|  |         lfs2_file_write(&lfs2, &file, wbuffer, size) => size; | ||||||
|  |         lfs2_file_rewind(&lfs2, &file) => 0; | ||||||
|  |         lfs2_file_read(&lfs2, &file, rbuffer, size) => size; | ||||||
|  |         memcmp(wbuffer, rbuffer, size) => 0; | ||||||
|  |         lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     } |     } | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Results ---" | echo "--- Many files with flush test ---" | ||||||
| tests/stats.py | scripts/test.py << TEST | ||||||
|  |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  | TEST | ||||||
|  | scripts/test.py << TEST | ||||||
|  |     // Create 300 files of 7 bytes | ||||||
|  |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |     for (unsigned i = 0; i < 300; i++) { | ||||||
|  |         sprintf(path, "file_%03d", i); | ||||||
|  |         lfs2_file_open(&lfs2, &file, path, | ||||||
|  |                 LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_EXCL) => 0; | ||||||
|  |         lfs2_size_t size = 7; | ||||||
|  |         uint8_t wbuffer[1024]; | ||||||
|  |         uint8_t rbuffer[1024]; | ||||||
|  |         snprintf((char*)wbuffer, size, "Hi %03d", i); | ||||||
|  |         lfs2_file_write(&lfs2, &file, wbuffer, size) => size; | ||||||
|  |         lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|  |         lfs2_file_open(&lfs2, &file, path, LFS2_O_RDONLY) => 0; | ||||||
|  |         lfs2_file_read(&lfs2, &file, rbuffer, size) => size; | ||||||
|  |         memcmp(wbuffer, rbuffer, size) => 0; | ||||||
|  |         lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |     } | ||||||
|  |     lfs2_unmount(&lfs2) => 0; | ||||||
|  | TEST | ||||||
|  |  | ||||||
|  | echo "--- Many files with power cycle test ---" | ||||||
|  | scripts/test.py << TEST | ||||||
|  |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  | TEST | ||||||
|  | scripts/test.py << TEST | ||||||
|  |     // Create 300 files of 7 bytes | ||||||
|  |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |     for (unsigned i = 0; i < 300; i++) { | ||||||
|  |         sprintf(path, "file_%03d", i); | ||||||
|  |         lfs2_file_open(&lfs2, &file, path, | ||||||
|  |                 LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_EXCL) => 0; | ||||||
|  |         lfs2_size_t size = 7; | ||||||
|  |         uint8_t wbuffer[1024]; | ||||||
|  |         uint8_t rbuffer[1024]; | ||||||
|  |         snprintf((char*)wbuffer, size, "Hi %03d", i); | ||||||
|  |         lfs2_file_write(&lfs2, &file, wbuffer, size) => size; | ||||||
|  |         lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |         lfs2_unmount(&lfs2) => 0; | ||||||
|  |  | ||||||
|  |         lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |         lfs2_file_open(&lfs2, &file, path, LFS2_O_RDONLY) => 0; | ||||||
|  |         lfs2_file_read(&lfs2, &file, rbuffer, size) => size; | ||||||
|  |         memcmp(wbuffer, rbuffer, size) => 0; | ||||||
|  |         lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |     } | ||||||
|  |     lfs2_unmount(&lfs2) => 0; | ||||||
|  | TEST | ||||||
|  |  | ||||||
|  | scripts/results.py | ||||||
|   | |||||||
| @@ -1,16 +1,18 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| set -eu | set -eu | ||||||
|  | export TEST_FILE=$0 | ||||||
|  | trap 'export TEST_LINE=$LINENO' DEBUG | ||||||
|  |  | ||||||
| echo "=== Formatting tests ===" | echo "=== Formatting tests ===" | ||||||
| rm -rf blocks | rm -rf blocks | ||||||
|  |  | ||||||
| echo "--- Basic formatting ---" | echo "--- Basic formatting ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Basic mounting ---" | echo "--- Basic mounting ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
| @@ -20,18 +22,18 @@ TEST | |||||||
| echo "--- Invalid superblocks ---" | echo "--- Invalid superblocks ---" | ||||||
| ln -f -s /dev/zero blocks/0 | ln -f -s /dev/zero blocks/0 | ||||||
| ln -f -s /dev/zero blocks/1 | ln -f -s /dev/zero blocks/1 | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => LFS2_ERR_NOSPC; |     lfs2_format(&lfs2, &cfg) => LFS2_ERR_NOSPC; | ||||||
| TEST | TEST | ||||||
| rm blocks/0 blocks/1 | rm blocks/0 blocks/1 | ||||||
|  |  | ||||||
| echo "--- Invalid mount ---" | echo "--- Invalid mount ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => LFS2_ERR_CORRUPT; |     lfs2_mount(&lfs2, &cfg) => LFS2_ERR_CORRUPT; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Expanding superblock ---" | echo "--- Expanding superblock ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     for (int i = 0; i < 100; i++) { |     for (int i = 0; i < 100; i++) { | ||||||
| @@ -40,11 +42,10 @@ tests/test.py << TEST | |||||||
|     } |     } | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "dummy") => 0; |     lfs2_mkdir(&lfs2, "dummy") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Results ---" | scripts/results.py | ||||||
| tests/stats.py |  | ||||||
|   | |||||||
| @@ -1,89 +1,93 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| set -eu | set -eu | ||||||
|  | export TEST_FILE=$0 | ||||||
|  | trap 'export TEST_LINE=$LINENO' DEBUG | ||||||
|  |  | ||||||
| echo "=== Interspersed tests ===" | echo "=== Interspersed tests ===" | ||||||
| rm -rf blocks | rm -rf blocks | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Interspersed file test ---" | echo "--- Interspersed file test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "a", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |     lfs2_file_t files[4]; | ||||||
|     lfs2_file_open(&lfs2, &file[1], "b", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |     lfs2_file_open(&lfs2, &files[0], "a", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[2], "c", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |     lfs2_file_open(&lfs2, &files[1], "b", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[3], "d", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |     lfs2_file_open(&lfs2, &files[2], "c", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|  |     lfs2_file_open(&lfs2, &files[3], "d", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|  |  | ||||||
|     for (int i = 0; i < 10; i++) { |     for (int i = 0; i < 10; i++) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], (const void*)"a", 1) => 1; |         lfs2_file_write(&lfs2, &files[0], (const void*)"a", 1) => 1; | ||||||
|         lfs2_file_write(&lfs2, &file[1], (const void*)"b", 1) => 1; |         lfs2_file_write(&lfs2, &files[1], (const void*)"b", 1) => 1; | ||||||
|         lfs2_file_write(&lfs2, &file[2], (const void*)"c", 1) => 1; |         lfs2_file_write(&lfs2, &files[2], (const void*)"c", 1) => 1; | ||||||
|         lfs2_file_write(&lfs2, &file[3], (const void*)"d", 1) => 1; |         lfs2_file_write(&lfs2, &files[3], (const void*)"d", 1) => 1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]); |     lfs2_file_close(&lfs2, &files[0]); | ||||||
|     lfs2_file_close(&lfs2, &file[1]); |     lfs2_file_close(&lfs2, &files[1]); | ||||||
|     lfs2_file_close(&lfs2, &file[2]); |     lfs2_file_close(&lfs2, &files[2]); | ||||||
|     lfs2_file_close(&lfs2, &file[3]); |     lfs2_file_close(&lfs2, &files[3]); | ||||||
|  |  | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "/") => 0; |     lfs2_dir_open(&lfs2, &dir, "/") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "a") => 0; |     strcmp(info.name, "a") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     info.size => 10; |     info.size => 10; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "b") => 0; |     strcmp(info.name, "b") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     info.size => 10; |     info.size => 10; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "c") => 0; |     strcmp(info.name, "c") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     info.size => 10; |     info.size => 10; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "d") => 0; |     strcmp(info.name, "d") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     info.size => 10; |     info.size => 10; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], "a", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &files[0], "a", LFS2_O_RDONLY) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[1], "b", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &files[1], "b", LFS2_O_RDONLY) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[2], "c", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &files[2], "c", LFS2_O_RDONLY) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[3], "d", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &files[3], "d", LFS2_O_RDONLY) => 0; | ||||||
|  |  | ||||||
|     for (int i = 0; i < 10; i++) { |     for (int i = 0; i < 10; i++) { | ||||||
|         lfs2_file_read(&lfs2, &file[0], buffer, 1) => 1; |         lfs2_file_read(&lfs2, &files[0], buffer, 1) => 1; | ||||||
|         buffer[0] => 'a'; |         buffer[0] => 'a'; | ||||||
|         lfs2_file_read(&lfs2, &file[1], buffer, 1) => 1; |         lfs2_file_read(&lfs2, &files[1], buffer, 1) => 1; | ||||||
|         buffer[0] => 'b'; |         buffer[0] => 'b'; | ||||||
|         lfs2_file_read(&lfs2, &file[2], buffer, 1) => 1; |         lfs2_file_read(&lfs2, &files[2], buffer, 1) => 1; | ||||||
|         buffer[0] => 'c'; |         buffer[0] => 'c'; | ||||||
|         lfs2_file_read(&lfs2, &file[3], buffer, 1) => 1; |         lfs2_file_read(&lfs2, &files[3], buffer, 1) => 1; | ||||||
|         buffer[0] => 'd'; |         buffer[0] => 'd'; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]); |     lfs2_file_close(&lfs2, &files[0]); | ||||||
|     lfs2_file_close(&lfs2, &file[1]); |     lfs2_file_close(&lfs2, &files[1]); | ||||||
|     lfs2_file_close(&lfs2, &file[2]); |     lfs2_file_close(&lfs2, &files[2]); | ||||||
|     lfs2_file_close(&lfs2, &file[3]); |     lfs2_file_close(&lfs2, &files[3]); | ||||||
|      |      | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Interspersed remove file test ---" | echo "--- Interspersed remove file test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "e", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |     lfs2_file_t files[4]; | ||||||
|  |     lfs2_file_open(&lfs2, &files[0], "e", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|  |  | ||||||
|     for (int i = 0; i < 5; i++) { |     for (int i = 0; i < 5; i++) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], (const void*)"e", 1) => 1; |         lfs2_file_write(&lfs2, &files[0], (const void*)"e", 1) => 1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_remove(&lfs2, "a") => 0; |     lfs2_remove(&lfs2, "a") => 0; | ||||||
| @@ -92,95 +96,95 @@ tests/test.py << TEST | |||||||
|     lfs2_remove(&lfs2, "d") => 0; |     lfs2_remove(&lfs2, "d") => 0; | ||||||
|  |  | ||||||
|     for (int i = 0; i < 5; i++) { |     for (int i = 0; i < 5; i++) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], (const void*)"e", 1) => 1; |         lfs2_file_write(&lfs2, &files[0], (const void*)"e", 1) => 1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]); |     lfs2_file_close(&lfs2, &files[0]); | ||||||
|  |  | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "/") => 0; |     lfs2_dir_open(&lfs2, &dir, "/") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "e") => 0; |     strcmp(info.name, "e") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     info.size => 10; |     info.size => 10; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], "e", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &files[0], "e", LFS2_O_RDONLY) => 0; | ||||||
|  |  | ||||||
|     for (int i = 0; i < 10; i++) { |     for (int i = 0; i < 10; i++) { | ||||||
|         lfs2_file_read(&lfs2, &file[0], buffer, 1) => 1; |         lfs2_file_read(&lfs2, &files[0], buffer, 1) => 1; | ||||||
|         buffer[0] => 'e'; |         buffer[0] => 'e'; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]); |     lfs2_file_close(&lfs2, &files[0]); | ||||||
|      |      | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Remove inconveniently test ---" | echo "--- Remove inconveniently test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "e", LFS2_O_WRONLY | LFS2_O_TRUNC) => 0; |     lfs2_file_t files[4]; | ||||||
|     lfs2_file_open(&lfs2, &file[1], "f", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |     lfs2_file_open(&lfs2, &files[0], "e", LFS2_O_WRONLY | LFS2_O_TRUNC) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[2], "g", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |     lfs2_file_open(&lfs2, &files[1], "f", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|  |     lfs2_file_open(&lfs2, &files[2], "g", LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|  |  | ||||||
|     for (int i = 0; i < 5; i++) { |     for (int i = 0; i < 5; i++) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], (const void*)"e", 1) => 1; |         lfs2_file_write(&lfs2, &files[0], (const void*)"e", 1) => 1; | ||||||
|         lfs2_file_write(&lfs2, &file[1], (const void*)"f", 1) => 1; |         lfs2_file_write(&lfs2, &files[1], (const void*)"f", 1) => 1; | ||||||
|         lfs2_file_write(&lfs2, &file[2], (const void*)"g", 1) => 1; |         lfs2_file_write(&lfs2, &files[2], (const void*)"g", 1) => 1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_remove(&lfs2, "f") => 0; |     lfs2_remove(&lfs2, "f") => 0; | ||||||
|  |  | ||||||
|     for (int i = 0; i < 5; i++) { |     for (int i = 0; i < 5; i++) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], (const void*)"e", 1) => 1; |         lfs2_file_write(&lfs2, &files[0], (const void*)"e", 1) => 1; | ||||||
|         lfs2_file_write(&lfs2, &file[1], (const void*)"f", 1) => 1; |         lfs2_file_write(&lfs2, &files[1], (const void*)"f", 1) => 1; | ||||||
|         lfs2_file_write(&lfs2, &file[2], (const void*)"g", 1) => 1; |         lfs2_file_write(&lfs2, &files[2], (const void*)"g", 1) => 1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]); |     lfs2_file_close(&lfs2, &files[0]); | ||||||
|     lfs2_file_close(&lfs2, &file[1]); |     lfs2_file_close(&lfs2, &files[1]); | ||||||
|     lfs2_file_close(&lfs2, &file[2]); |     lfs2_file_close(&lfs2, &files[2]); | ||||||
|  |  | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "/") => 0; |     lfs2_dir_open(&lfs2, &dir, "/") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "e") => 0; |     strcmp(info.name, "e") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     info.size => 10; |     info.size => 10; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "g") => 0; |     strcmp(info.name, "g") => 0; | ||||||
|     info.type => LFS2_TYPE_REG; |     info.type => LFS2_TYPE_REG; | ||||||
|     info.size => 10; |     info.size => 10; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], "e", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &files[0], "e", LFS2_O_RDONLY) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[1], "g", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &files[1], "g", LFS2_O_RDONLY) => 0; | ||||||
|  |  | ||||||
|     for (int i = 0; i < 10; i++) { |     for (int i = 0; i < 10; i++) { | ||||||
|         lfs2_file_read(&lfs2, &file[0], buffer, 1) => 1; |         lfs2_file_read(&lfs2, &files[0], buffer, 1) => 1; | ||||||
|         buffer[0] => 'e'; |         buffer[0] => 'e'; | ||||||
|         lfs2_file_read(&lfs2, &file[1], buffer, 1) => 1; |         lfs2_file_read(&lfs2, &files[1], buffer, 1) => 1; | ||||||
|         buffer[0] => 'g'; |         buffer[0] => 'g'; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]); |     lfs2_file_close(&lfs2, &files[0]); | ||||||
|     lfs2_file_close(&lfs2, &file[1]); |     lfs2_file_close(&lfs2, &files[1]); | ||||||
|      |      | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Results ---" | scripts/results.py | ||||||
| tests/stats.py |  | ||||||
|   | |||||||
| @@ -1,9 +1,11 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| set -eu | set -eu | ||||||
|  | export TEST_FILE=$0 | ||||||
|  | trap 'export TEST_LINE=$LINENO' DEBUG | ||||||
|  |  | ||||||
| echo "=== Move tests ===" | echo "=== Move tests ===" | ||||||
| rm -rf blocks | rm -rf blocks | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
| @@ -17,272 +19,272 @@ tests/test.py << TEST | |||||||
|     lfs2_mkdir(&lfs2, "a/hi/bonjour") => 0; |     lfs2_mkdir(&lfs2, "a/hi/bonjour") => 0; | ||||||
|     lfs2_mkdir(&lfs2, "a/hi/ohayo") => 0; |     lfs2_mkdir(&lfs2, "a/hi/ohayo") => 0; | ||||||
|  |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], "a/hello", LFS2_O_CREAT | LFS2_O_WRONLY) => 0; |     lfs2_file_open(&lfs2, &file, "a/hello", LFS2_O_CREAT | LFS2_O_WRONLY) => 0; | ||||||
|     lfs2_file_write(&lfs2, &file[0], "hola\n", 5) => 5; |     lfs2_file_write(&lfs2, &file, "hola\n", 5) => 5; | ||||||
|     lfs2_file_write(&lfs2, &file[0], "bonjour\n", 8) => 8; |     lfs2_file_write(&lfs2, &file, "bonjour\n", 8) => 8; | ||||||
|     lfs2_file_write(&lfs2, &file[0], "ohayo\n", 6) => 6; |     lfs2_file_write(&lfs2, &file, "ohayo\n", 6) => 6; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Move file ---" | echo "--- Move file ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_rename(&lfs2, "a/hello", "b/hello") => 0; |     lfs2_rename(&lfs2, "a/hello", "b/hello") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "a") => 0; |     lfs2_dir_open(&lfs2, &dir, "a") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "hi") => 0; |     strcmp(info.name, "hi") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "b") => 0; |     lfs2_dir_open(&lfs2, &dir, "b") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "hello") => 0; |     strcmp(info.name, "hello") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Move file corrupt source ---" | echo "--- Move file corrupt source ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_rename(&lfs2, "b/hello", "c/hello") => 0; |     lfs2_rename(&lfs2, "b/hello", "c/hello") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/corrupt.py -n 1 | scripts/corrupt.py -n 1 | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "b") => 0; |     lfs2_dir_open(&lfs2, &dir, "b") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "c") => 0; |     lfs2_dir_open(&lfs2, &dir, "c") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "hello") => 0; |     strcmp(info.name, "hello") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Move file corrupt source and dest ---" | echo "--- Move file corrupt source and dest ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_rename(&lfs2, "c/hello", "d/hello") => 0; |     lfs2_rename(&lfs2, "c/hello", "d/hello") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/corrupt.py -n 2 | scripts/corrupt.py -n 2 | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "c") => 0; |     lfs2_dir_open(&lfs2, &dir, "c") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "hello") => 0; |     strcmp(info.name, "hello") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "d") => 0; |     lfs2_dir_open(&lfs2, &dir, "d") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Move file after corrupt ---" | echo "--- Move file after corrupt ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_rename(&lfs2, "c/hello", "d/hello") => 0; |     lfs2_rename(&lfs2, "c/hello", "d/hello") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "c") => 0; |     lfs2_dir_open(&lfs2, &dir, "c") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "d") => 0; |     lfs2_dir_open(&lfs2, &dir, "d") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "hello") => 0; |     strcmp(info.name, "hello") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Move dir ---" | echo "--- Move dir ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_rename(&lfs2, "a/hi", "b/hi") => 0; |     lfs2_rename(&lfs2, "a/hi", "b/hi") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "a") => 0; |     lfs2_dir_open(&lfs2, &dir, "a") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "b") => 0; |     lfs2_dir_open(&lfs2, &dir, "b") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "hi") => 0; |     strcmp(info.name, "hi") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Move dir corrupt source ---" | echo "--- Move dir corrupt source ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_rename(&lfs2, "b/hi", "c/hi") => 0; |     lfs2_rename(&lfs2, "b/hi", "c/hi") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/corrupt.py -n 1 | scripts/corrupt.py -n 1 | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "b") => 0; |     lfs2_dir_open(&lfs2, &dir, "b") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "c") => 0; |     lfs2_dir_open(&lfs2, &dir, "c") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "hi") => 0; |     strcmp(info.name, "hi") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Move dir corrupt source and dest ---" | echo "--- Move dir corrupt source and dest ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_rename(&lfs2, "c/hi", "d/hi") => 0; |     lfs2_rename(&lfs2, "c/hi", "d/hi") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/corrupt.py -n 2 | scripts/corrupt.py -n 2 | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "c") => 0; |     lfs2_dir_open(&lfs2, &dir, "c") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "hi") => 0; |     strcmp(info.name, "hi") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "d") => 0; |     lfs2_dir_open(&lfs2, &dir, "d") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "hello") => 0; |     strcmp(info.name, "hello") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Move dir after corrupt ---" | echo "--- Move dir after corrupt ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_rename(&lfs2, "c/hi", "d/hi") => 0; |     lfs2_rename(&lfs2, "c/hi", "d/hi") => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "c") => 0; |     lfs2_dir_open(&lfs2, &dir, "c") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "d") => 0; |     lfs2_dir_open(&lfs2, &dir, "d") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "hello") => 0; |     strcmp(info.name, "hello") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "hi") => 0; |     strcmp(info.name, "hi") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Move check ---" | echo "--- Move check ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "a/hi") => LFS2_ERR_NOENT; |     lfs2_dir_open(&lfs2, &dir, "a/hi") => LFS2_ERR_NOENT; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "b/hi") => LFS2_ERR_NOENT; |     lfs2_dir_open(&lfs2, &dir, "b/hi") => LFS2_ERR_NOENT; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "c/hi") => LFS2_ERR_NOENT; |     lfs2_dir_open(&lfs2, &dir, "c/hi") => LFS2_ERR_NOENT; | ||||||
|  |  | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "d/hi") => 0; |     lfs2_dir_open(&lfs2, &dir, "d/hi") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "bonjour") => 0; |     strcmp(info.name, "bonjour") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "hola") => 0; |     strcmp(info.name, "hola") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "ohayo") => 0; |     strcmp(info.name, "ohayo") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|  |  | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "a/hello") => LFS2_ERR_NOENT; |     lfs2_dir_open(&lfs2, &dir, "a/hello") => LFS2_ERR_NOENT; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "b/hello") => LFS2_ERR_NOENT; |     lfs2_dir_open(&lfs2, &dir, "b/hello") => LFS2_ERR_NOENT; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "c/hello") => LFS2_ERR_NOENT; |     lfs2_dir_open(&lfs2, &dir, "c/hello") => LFS2_ERR_NOENT; | ||||||
|  |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], "d/hello", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &file, "d/hello", LFS2_O_RDONLY) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, 5) => 5; |     lfs2_file_read(&lfs2, &file, buffer, 5) => 5; | ||||||
|     memcmp(buffer, "hola\n", 5) => 0; |     memcmp(buffer, "hola\n", 5) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, 8) => 8; |     lfs2_file_read(&lfs2, &file, buffer, 8) => 8; | ||||||
|     memcmp(buffer, "bonjour\n", 8) => 0; |     memcmp(buffer, "bonjour\n", 8) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, 6) => 6; |     lfs2_file_read(&lfs2, &file, buffer, 6) => 6; | ||||||
|     memcmp(buffer, "ohayo\n", 6) => 0; |     memcmp(buffer, "ohayo\n", 6) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Move state stealing ---" | echo "--- Move state stealing ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     lfs2_remove(&lfs2, "b") => 0; |     lfs2_remove(&lfs2, "b") => 0; | ||||||
| @@ -290,43 +292,42 @@ tests/test.py << TEST | |||||||
|  |  | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "a/hi") => LFS2_ERR_NOENT; |     lfs2_dir_open(&lfs2, &dir, "a/hi") => LFS2_ERR_NOENT; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "b") => LFS2_ERR_NOENT; |     lfs2_dir_open(&lfs2, &dir, "b") => LFS2_ERR_NOENT; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "c") => LFS2_ERR_NOENT; |     lfs2_dir_open(&lfs2, &dir, "c") => LFS2_ERR_NOENT; | ||||||
|  |  | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "d/hi") => 0; |     lfs2_dir_open(&lfs2, &dir, "d/hi") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "bonjour") => 0; |     strcmp(info.name, "bonjour") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "hola") => 0; |     strcmp(info.name, "hola") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "ohayo") => 0; |     strcmp(info.name, "ohayo") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 0; |     lfs2_dir_read(&lfs2, &dir, &info) => 0; | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|  |  | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "a/hello") => LFS2_ERR_NOENT; |     lfs2_dir_open(&lfs2, &dir, "a/hello") => LFS2_ERR_NOENT; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "b") => LFS2_ERR_NOENT; |     lfs2_dir_open(&lfs2, &dir, "b") => LFS2_ERR_NOENT; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "c") => LFS2_ERR_NOENT; |     lfs2_dir_open(&lfs2, &dir, "c") => LFS2_ERR_NOENT; | ||||||
|  |  | ||||||
|     lfs2_file_open(&lfs2, &file[0], "d/hello", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &file, "d/hello", LFS2_O_RDONLY) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, 5) => 5; |     lfs2_file_read(&lfs2, &file, buffer, 5) => 5; | ||||||
|     memcmp(buffer, "hola\n", 5) => 0; |     memcmp(buffer, "hola\n", 5) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, 8) => 8; |     lfs2_file_read(&lfs2, &file, buffer, 8) => 8; | ||||||
|     memcmp(buffer, "bonjour\n", 8) => 0; |     memcmp(buffer, "bonjour\n", 8) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, 6) => 6; |     lfs2_file_read(&lfs2, &file, buffer, 6) => 6; | ||||||
|     memcmp(buffer, "ohayo\n", 6) => 0; |     memcmp(buffer, "ohayo\n", 6) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|  |  | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
|  |  | ||||||
| echo "--- Results ---" | scripts/results.py | ||||||
| tests/stats.py |  | ||||||
|   | |||||||
| @@ -1,14 +1,16 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| set -eu | set -eu | ||||||
|  | export TEST_FILE=$0 | ||||||
|  | trap 'export TEST_LINE=$LINENO' DEBUG | ||||||
|  |  | ||||||
| echo "=== Orphan tests ===" | echo "=== Orphan tests ===" | ||||||
| rm -rf blocks | rm -rf blocks | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Orphan test ---" | echo "--- Orphan test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "parent") => 0; |     lfs2_mkdir(&lfs2, "parent") => 0; | ||||||
|     lfs2_mkdir(&lfs2, "parent/orphan") => 0; |     lfs2_mkdir(&lfs2, "parent/orphan") => 0; | ||||||
| @@ -17,8 +19,8 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
| # corrupt most recent commit, this should be the update to the previous | # corrupt most recent commit, this should be the update to the previous | ||||||
| # linked-list entry and should orphan the child | # linked-list entry and should orphan the child | ||||||
| tests/corrupt.py | scripts/corrupt.py | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     lfs2_stat(&lfs2, "parent/orphan", &info) => LFS2_ERR_NOENT; |     lfs2_stat(&lfs2, "parent/orphan", &info) => LFS2_ERR_NOENT; | ||||||
| @@ -41,5 +43,4 @@ tests/test.py << TEST | |||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Results ---" | scripts/results.py | ||||||
| tests/stats.py |  | ||||||
|   | |||||||
| @@ -1,13 +1,15 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| set -eu | set -eu | ||||||
|  | export TEST_FILE=$0 | ||||||
|  | trap 'export TEST_LINE=$LINENO' DEBUG | ||||||
|  |  | ||||||
| echo "=== Path tests ===" | echo "=== Path tests ===" | ||||||
| rm -rf blocks | rm -rf blocks | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "tea") => 0; |     lfs2_mkdir(&lfs2, "tea") => 0; | ||||||
|     lfs2_mkdir(&lfs2, "coffee") => 0; |     lfs2_mkdir(&lfs2, "coffee") => 0; | ||||||
| @@ -25,7 +27,7 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Root path tests ---" | echo "--- Root path tests ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_stat(&lfs2, "tea/hottea", &info) => 0; |     lfs2_stat(&lfs2, "tea/hottea", &info) => 0; | ||||||
|     strcmp(info.name, "hottea") => 0; |     strcmp(info.name, "hottea") => 0; | ||||||
| @@ -39,7 +41,7 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Redundant slash path tests ---" | echo "--- Redundant slash path tests ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_stat(&lfs2, "/tea/hottea", &info) => 0; |     lfs2_stat(&lfs2, "/tea/hottea", &info) => 0; | ||||||
|     strcmp(info.name, "hottea") => 0; |     strcmp(info.name, "hottea") => 0; | ||||||
| @@ -55,7 +57,7 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Dot path tests ---" | echo "--- Dot path tests ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_stat(&lfs2, "./tea/hottea", &info) => 0; |     lfs2_stat(&lfs2, "./tea/hottea", &info) => 0; | ||||||
|     strcmp(info.name, "hottea") => 0; |     strcmp(info.name, "hottea") => 0; | ||||||
| @@ -73,7 +75,7 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Dot dot path tests ---" | echo "--- Dot dot path tests ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_stat(&lfs2, "coffee/../tea/hottea", &info) => 0; |     lfs2_stat(&lfs2, "coffee/../tea/hottea", &info) => 0; | ||||||
|     strcmp(info.name, "hottea") => 0; |     strcmp(info.name, "hottea") => 0; | ||||||
| @@ -91,7 +93,7 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Trailing dot path tests ---" | echo "--- Trailing dot path tests ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_stat(&lfs2, "tea/hottea/", &info) => 0; |     lfs2_stat(&lfs2, "tea/hottea/", &info) => 0; | ||||||
|     strcmp(info.name, "hottea") => 0; |     strcmp(info.name, "hottea") => 0; | ||||||
| @@ -107,7 +109,7 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Root dot dot path tests ---" | echo "--- Root dot dot path tests ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_stat(&lfs2, "coffee/../../../../../../tea/hottea", &info) => 0; |     lfs2_stat(&lfs2, "coffee/../../../../../../tea/hottea", &info) => 0; | ||||||
|     strcmp(info.name, "hottea") => 0; |     strcmp(info.name, "hottea") => 0; | ||||||
| @@ -119,14 +121,14 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Root tests ---" | echo "--- Root tests ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_stat(&lfs2, "/", &info) => 0; |     lfs2_stat(&lfs2, "/", &info) => 0; | ||||||
|     info.type => LFS2_TYPE_DIR; |     info.type => LFS2_TYPE_DIR; | ||||||
|     strcmp(info.name, "/") => 0; |     strcmp(info.name, "/") => 0; | ||||||
|  |  | ||||||
|     lfs2_mkdir(&lfs2, "/") => LFS2_ERR_EXIST; |     lfs2_mkdir(&lfs2, "/") => LFS2_ERR_EXIST; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "/", LFS2_O_WRONLY | LFS2_O_CREAT) |     lfs2_file_open(&lfs2, &file, "/", LFS2_O_WRONLY | LFS2_O_CREAT) | ||||||
|         => LFS2_ERR_ISDIR; |         => LFS2_ERR_ISDIR; | ||||||
|  |  | ||||||
|     // more corner cases |     // more corner cases | ||||||
| @@ -140,7 +142,7 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Sketchy path tests ---" | echo "--- Sketchy path tests ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "dirt/ground") => LFS2_ERR_NOENT; |     lfs2_mkdir(&lfs2, "dirt/ground") => LFS2_ERR_NOENT; | ||||||
|     lfs2_mkdir(&lfs2, "dirt/ground/earth") => LFS2_ERR_NOENT; |     lfs2_mkdir(&lfs2, "dirt/ground/earth") => LFS2_ERR_NOENT; | ||||||
| @@ -148,7 +150,7 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Superblock conflict test ---" | echo "--- Superblock conflict test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "littlefs") => 0; |     lfs2_mkdir(&lfs2, "littlefs") => 0; | ||||||
|     lfs2_remove(&lfs2, "littlefs") => 0; |     lfs2_remove(&lfs2, "littlefs") => 0; | ||||||
| @@ -156,46 +158,45 @@ tests/test.py << TEST | |||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Max path test ---" | echo "--- Max path test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     memset(buffer, 'w', LFS2_NAME_MAX+1); |     memset(path, 'w', LFS2_NAME_MAX+1); | ||||||
|     buffer[LFS2_NAME_MAX+2] = '\0'; |     path[LFS2_NAME_MAX+2] = '\0'; | ||||||
|     lfs2_mkdir(&lfs2, (char*)buffer) => LFS2_ERR_NAMETOOLONG; |     lfs2_mkdir(&lfs2, path) => LFS2_ERR_NAMETOOLONG; | ||||||
|     lfs2_file_open(&lfs2, &file[0], (char*)buffer, |     lfs2_file_open(&lfs2, &file, path, | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT) => LFS2_ERR_NAMETOOLONG; |             LFS2_O_WRONLY | LFS2_O_CREAT) => LFS2_ERR_NAMETOOLONG; | ||||||
|  |  | ||||||
|     memcpy(buffer, "coffee/", strlen("coffee/")); |     memcpy(path, "coffee/", strlen("coffee/")); | ||||||
|     memset(buffer+strlen("coffee/"), 'w', LFS2_NAME_MAX+1); |     memset(path+strlen("coffee/"), 'w', LFS2_NAME_MAX+1); | ||||||
|     buffer[strlen("coffee/")+LFS2_NAME_MAX+2] = '\0'; |     path[strlen("coffee/")+LFS2_NAME_MAX+2] = '\0'; | ||||||
|     lfs2_mkdir(&lfs2, (char*)buffer) => LFS2_ERR_NAMETOOLONG; |     lfs2_mkdir(&lfs2, path) => LFS2_ERR_NAMETOOLONG; | ||||||
|     lfs2_file_open(&lfs2, &file[0], (char*)buffer, |     lfs2_file_open(&lfs2, &file, path, | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT) => LFS2_ERR_NAMETOOLONG; |             LFS2_O_WRONLY | LFS2_O_CREAT) => LFS2_ERR_NAMETOOLONG; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Really big path test ---" | echo "--- Really big path test ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     memset(buffer, 'w', LFS2_NAME_MAX); |     memset(path, 'w', LFS2_NAME_MAX); | ||||||
|     buffer[LFS2_NAME_MAX+1] = '\0'; |     path[LFS2_NAME_MAX+1] = '\0'; | ||||||
|     lfs2_mkdir(&lfs2, (char*)buffer) => 0; |     lfs2_mkdir(&lfs2, path) => 0; | ||||||
|     lfs2_remove(&lfs2, (char*)buffer) => 0; |     lfs2_remove(&lfs2, path) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], (char*)buffer, |     lfs2_file_open(&lfs2, &file, path, | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_remove(&lfs2, (char*)buffer) => 0; |     lfs2_remove(&lfs2, path) => 0; | ||||||
|  |  | ||||||
|     memcpy(buffer, "coffee/", strlen("coffee/")); |     memcpy(path, "coffee/", strlen("coffee/")); | ||||||
|     memset(buffer+strlen("coffee/"), 'w', LFS2_NAME_MAX); |     memset(path+strlen("coffee/"), 'w', LFS2_NAME_MAX); | ||||||
|     buffer[strlen("coffee/")+LFS2_NAME_MAX+1] = '\0'; |     path[strlen("coffee/")+LFS2_NAME_MAX+1] = '\0'; | ||||||
|     lfs2_mkdir(&lfs2, (char*)buffer) => 0; |     lfs2_mkdir(&lfs2, path) => 0; | ||||||
|     lfs2_remove(&lfs2, (char*)buffer) => 0; |     lfs2_remove(&lfs2, path) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], (char*)buffer, |     lfs2_file_open(&lfs2, &file, path, | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_remove(&lfs2, (char*)buffer) => 0; |     lfs2_remove(&lfs2, path) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Results ---" | scripts/results.py | ||||||
| tests/stats.py |  | ||||||
|   | |||||||
| @@ -1,429 +1,431 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| set -eu | set -eu | ||||||
|  | export TEST_FILE=$0 | ||||||
|  | trap 'export TEST_LINE=$LINENO' DEBUG | ||||||
|  |  | ||||||
|  | echo "=== Seek tests ===" | ||||||
|  |  | ||||||
| SMALLSIZE=4 | SMALLSIZE=4 | ||||||
| MEDIUMSIZE=128 | MEDIUMSIZE=128 | ||||||
| LARGESIZE=132 | LARGESIZE=132 | ||||||
|  |  | ||||||
| echo "=== Seek tests ===" |  | ||||||
| rm -rf blocks | rm -rf blocks | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_mkdir(&lfs2, "hello") => 0; |     lfs2_mkdir(&lfs2, "hello") => 0; | ||||||
|     for (int i = 0; i < $LARGESIZE; i++) { |     for (int i = 0; i < $LARGESIZE; i++) { | ||||||
|         sprintf((char*)buffer, "hello/kitty%03d", i); |         sprintf(path, "hello/kitty%03d", i); | ||||||
|         lfs2_file_open(&lfs2, &file[0], (char*)buffer, |         lfs2_file_open(&lfs2, &file, path, | ||||||
|                 LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_APPEND) => 0; |                 LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_APPEND) => 0; | ||||||
|  |  | ||||||
|         size = strlen("kittycatcat"); |         lfs2_size_t size = strlen("kittycatcat"); | ||||||
|         memcpy(buffer, "kittycatcat", size); |         memcpy(buffer, "kittycatcat", size); | ||||||
|         for (int j = 0; j < $LARGESIZE; j++) { |         for (int j = 0; j < $LARGESIZE; j++) { | ||||||
|             lfs2_file_write(&lfs2, &file[0], buffer, size); |             lfs2_file_write(&lfs2, &file, buffer, size); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         lfs2_file_close(&lfs2, &file[0]) => 0; |         lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     } |     } | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Simple dir seek ---" | echo "--- Simple dir seek ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "hello") => 0; |     lfs2_dir_open(&lfs2, &dir, "hello") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|  |  | ||||||
|     lfs2_soff_t pos; |     lfs2_soff_t pos; | ||||||
|     int i; |     int i; | ||||||
|     for (i = 0; i < $SMALLSIZE; i++) { |     for (i = 0; i < $SMALLSIZE; i++) { | ||||||
|         sprintf((char*)buffer, "kitty%03d", i); |         sprintf(path, "kitty%03d", i); | ||||||
|         lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |         lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|         strcmp(info.name, (char*)buffer) => 0; |         strcmp(info.name, path) => 0; | ||||||
|         pos = lfs2_dir_tell(&lfs2, &dir[0]); |         pos = lfs2_dir_tell(&lfs2, &dir); | ||||||
|     } |     } | ||||||
|     pos >= 0 => 1; |     pos >= 0 => 1; | ||||||
|  |  | ||||||
|     lfs2_dir_seek(&lfs2, &dir[0], pos) => 0; |     lfs2_dir_seek(&lfs2, &dir, pos) => 0; | ||||||
|     sprintf((char*)buffer, "kitty%03d", i); |     sprintf(path, "kitty%03d", i); | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, (char*)buffer) => 0; |     strcmp(info.name, path) => 0; | ||||||
|  |  | ||||||
|     lfs2_dir_rewind(&lfs2, &dir[0]) => 0; |     lfs2_dir_rewind(&lfs2, &dir) => 0; | ||||||
|     sprintf((char*)buffer, "kitty%03d", 0); |     sprintf(path, "kitty%03d", 0); | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, (char*)buffer) => 0; |     strcmp(info.name, path) => 0; | ||||||
|  |  | ||||||
|     lfs2_dir_seek(&lfs2, &dir[0], pos) => 0; |     lfs2_dir_seek(&lfs2, &dir, pos) => 0; | ||||||
|     sprintf((char*)buffer, "kitty%03d", i); |     sprintf(path, "kitty%03d", i); | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, (char*)buffer) => 0; |     strcmp(info.name, path) => 0; | ||||||
|  |  | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Large dir seek ---" | echo "--- Large dir seek ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_dir_open(&lfs2, &dir[0], "hello") => 0; |     lfs2_dir_open(&lfs2, &dir, "hello") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|  |  | ||||||
|     lfs2_soff_t pos; |     lfs2_soff_t pos; | ||||||
|     int i; |     int i; | ||||||
|     for (i = 0; i < $MEDIUMSIZE; i++) { |     for (i = 0; i < $MEDIUMSIZE; i++) { | ||||||
|         sprintf((char*)buffer, "kitty%03d", i); |         sprintf(path, "kitty%03d", i); | ||||||
|         lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |         lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|         strcmp(info.name, (char*)buffer) => 0; |         strcmp(info.name, path) => 0; | ||||||
|         pos = lfs2_dir_tell(&lfs2, &dir[0]); |         pos = lfs2_dir_tell(&lfs2, &dir); | ||||||
|     } |     } | ||||||
|     pos >= 0 => 1; |     pos >= 0 => 1; | ||||||
|  |  | ||||||
|     lfs2_dir_seek(&lfs2, &dir[0], pos) => 0; |     lfs2_dir_seek(&lfs2, &dir, pos) => 0; | ||||||
|     sprintf((char*)buffer, "kitty%03d", i); |     sprintf(path, "kitty%03d", i); | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, (char*)buffer) => 0; |     strcmp(info.name, path) => 0; | ||||||
|  |  | ||||||
|     lfs2_dir_rewind(&lfs2, &dir[0]) => 0; |     lfs2_dir_rewind(&lfs2, &dir) => 0; | ||||||
|     sprintf((char*)buffer, "kitty%03d", 0); |     sprintf(path, "kitty%03d", 0); | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, ".") => 0; |     strcmp(info.name, ".") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, "..") => 0; |     strcmp(info.name, "..") => 0; | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, (char*)buffer) => 0; |     strcmp(info.name, path) => 0; | ||||||
|  |  | ||||||
|     lfs2_dir_seek(&lfs2, &dir[0], pos) => 0; |     lfs2_dir_seek(&lfs2, &dir, pos) => 0; | ||||||
|     sprintf((char*)buffer, "kitty%03d", i); |     sprintf(path, "kitty%03d", i); | ||||||
|     lfs2_dir_read(&lfs2, &dir[0], &info) => 1; |     lfs2_dir_read(&lfs2, &dir, &info) => 1; | ||||||
|     strcmp(info.name, (char*)buffer) => 0; |     strcmp(info.name, path) => 0; | ||||||
|  |  | ||||||
|     lfs2_dir_close(&lfs2, &dir[0]) => 0; |     lfs2_dir_close(&lfs2, &dir) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Simple file seek ---" | echo "--- Simple file seek ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "hello/kitty042", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &file, "hello/kitty042", LFS2_O_RDONLY) => 0; | ||||||
|  |  | ||||||
|     lfs2_soff_t pos; |     lfs2_soff_t pos; | ||||||
|     size = strlen("kittycatcat"); |     lfs2_size_t size = strlen("kittycatcat"); | ||||||
|     for (int i = 0; i < $SMALLSIZE; i++) { |     for (int i = 0; i < $SMALLSIZE; i++) { | ||||||
|         lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|         memcmp(buffer, "kittycatcat", size) => 0; |         memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|         pos = lfs2_file_tell(&lfs2, &file[0]); |         pos = lfs2_file_tell(&lfs2, &file); | ||||||
|     } |     } | ||||||
|     pos >= 0 => 1; |     pos >= 0 => 1; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], pos, LFS2_SEEK_SET) => pos; |     lfs2_file_seek(&lfs2, &file, pos, LFS2_SEEK_SET) => pos; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_rewind(&lfs2, &file[0]) => 0; |     lfs2_file_rewind(&lfs2, &file) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], 0, LFS2_SEEK_CUR) => size; |     lfs2_file_seek(&lfs2, &file, 0, LFS2_SEEK_CUR) => size; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], size, LFS2_SEEK_CUR) => 3*size; |     lfs2_file_seek(&lfs2, &file, size, LFS2_SEEK_CUR) => 3*size; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], pos, LFS2_SEEK_SET) => pos; |     lfs2_file_seek(&lfs2, &file, pos, LFS2_SEEK_SET) => pos; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], -size, LFS2_SEEK_CUR) => pos; |     lfs2_file_seek(&lfs2, &file, -size, LFS2_SEEK_CUR) => pos; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], -size, LFS2_SEEK_END) >= 0 => 1; |     lfs2_file_seek(&lfs2, &file, -size, LFS2_SEEK_END) >= 0 => 1; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     size = lfs2_file_size(&lfs2, &file[0]); |     size = lfs2_file_size(&lfs2, &file); | ||||||
|     lfs2_file_seek(&lfs2, &file[0], 0, LFS2_SEEK_CUR) => size; |     lfs2_file_seek(&lfs2, &file, 0, LFS2_SEEK_CUR) => size; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Large file seek ---" | echo "--- Large file seek ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "hello/kitty042", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &file, "hello/kitty042", LFS2_O_RDONLY) => 0; | ||||||
|  |  | ||||||
|     lfs2_soff_t pos; |     lfs2_soff_t pos; | ||||||
|     size = strlen("kittycatcat"); |     lfs2_size_t size = strlen("kittycatcat"); | ||||||
|     for (int i = 0; i < $MEDIUMSIZE; i++) { |     for (int i = 0; i < $MEDIUMSIZE; i++) { | ||||||
|         lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|         memcmp(buffer, "kittycatcat", size) => 0; |         memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|         pos = lfs2_file_tell(&lfs2, &file[0]); |         pos = lfs2_file_tell(&lfs2, &file); | ||||||
|     } |     } | ||||||
|     pos >= 0 => 1; |     pos >= 0 => 1; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], pos, LFS2_SEEK_SET) => pos; |     lfs2_file_seek(&lfs2, &file, pos, LFS2_SEEK_SET) => pos; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_rewind(&lfs2, &file[0]) => 0; |     lfs2_file_rewind(&lfs2, &file) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], 0, LFS2_SEEK_CUR) => size; |     lfs2_file_seek(&lfs2, &file, 0, LFS2_SEEK_CUR) => size; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], size, LFS2_SEEK_CUR) => 3*size; |     lfs2_file_seek(&lfs2, &file, size, LFS2_SEEK_CUR) => 3*size; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], pos, LFS2_SEEK_SET) => pos; |     lfs2_file_seek(&lfs2, &file, pos, LFS2_SEEK_SET) => pos; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], -size, LFS2_SEEK_CUR) => pos; |     lfs2_file_seek(&lfs2, &file, -size, LFS2_SEEK_CUR) => pos; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], -size, LFS2_SEEK_END) >= 0 => 1; |     lfs2_file_seek(&lfs2, &file, -size, LFS2_SEEK_END) >= 0 => 1; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     size = lfs2_file_size(&lfs2, &file[0]); |     size = lfs2_file_size(&lfs2, &file); | ||||||
|     lfs2_file_seek(&lfs2, &file[0], 0, LFS2_SEEK_CUR) => size; |     lfs2_file_seek(&lfs2, &file, 0, LFS2_SEEK_CUR) => size; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Simple file seek and write ---" | echo "--- Simple file seek and write ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "hello/kitty042", LFS2_O_RDWR) => 0; |     lfs2_file_open(&lfs2, &file, "hello/kitty042", LFS2_O_RDWR) => 0; | ||||||
|  |  | ||||||
|     lfs2_soff_t pos; |     lfs2_soff_t pos; | ||||||
|     size = strlen("kittycatcat"); |     lfs2_size_t size = strlen("kittycatcat"); | ||||||
|     for (int i = 0; i < $SMALLSIZE; i++) { |     for (int i = 0; i < $SMALLSIZE; i++) { | ||||||
|         lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|         memcmp(buffer, "kittycatcat", size) => 0; |         memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|         pos = lfs2_file_tell(&lfs2, &file[0]); |         pos = lfs2_file_tell(&lfs2, &file); | ||||||
|     } |     } | ||||||
|     pos >= 0 => 1; |     pos >= 0 => 1; | ||||||
|  |  | ||||||
|     memcpy(buffer, "doggodogdog", size); |     memcpy(buffer, "doggodogdog", size); | ||||||
|     lfs2_file_seek(&lfs2, &file[0], pos, LFS2_SEEK_SET) => pos; |     lfs2_file_seek(&lfs2, &file, pos, LFS2_SEEK_SET) => pos; | ||||||
|     lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], pos, LFS2_SEEK_SET) => pos; |     lfs2_file_seek(&lfs2, &file, pos, LFS2_SEEK_SET) => pos; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "doggodogdog", size) => 0; |     memcmp(buffer, "doggodogdog", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_rewind(&lfs2, &file[0]) => 0; |     lfs2_file_rewind(&lfs2, &file) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], pos, LFS2_SEEK_SET) => pos; |     lfs2_file_seek(&lfs2, &file, pos, LFS2_SEEK_SET) => pos; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "doggodogdog", size) => 0; |     memcmp(buffer, "doggodogdog", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], -size, LFS2_SEEK_END) >= 0 => 1; |     lfs2_file_seek(&lfs2, &file, -size, LFS2_SEEK_END) >= 0 => 1; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     size = lfs2_file_size(&lfs2, &file[0]); |     size = lfs2_file_size(&lfs2, &file); | ||||||
|     lfs2_file_seek(&lfs2, &file[0], 0, LFS2_SEEK_CUR) => size; |     lfs2_file_seek(&lfs2, &file, 0, LFS2_SEEK_CUR) => size; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Large file seek and write ---" | echo "--- Large file seek and write ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "hello/kitty042", LFS2_O_RDWR) => 0; |     lfs2_file_open(&lfs2, &file, "hello/kitty042", LFS2_O_RDWR) => 0; | ||||||
|  |  | ||||||
|     lfs2_soff_t pos; |     lfs2_soff_t pos; | ||||||
|     size = strlen("kittycatcat"); |     lfs2_size_t size = strlen("kittycatcat"); | ||||||
|     for (int i = 0; i < $MEDIUMSIZE; i++) { |     for (int i = 0; i < $MEDIUMSIZE; i++) { | ||||||
|         lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|         if (i != $SMALLSIZE) { |         if (i != $SMALLSIZE) { | ||||||
|             memcmp(buffer, "kittycatcat", size) => 0; |             memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|         } |         } | ||||||
|         pos = lfs2_file_tell(&lfs2, &file[0]); |         pos = lfs2_file_tell(&lfs2, &file); | ||||||
|     } |     } | ||||||
|     pos >= 0 => 1; |     pos >= 0 => 1; | ||||||
|  |  | ||||||
|     memcpy(buffer, "doggodogdog", size); |     memcpy(buffer, "doggodogdog", size); | ||||||
|     lfs2_file_seek(&lfs2, &file[0], pos, LFS2_SEEK_SET) => pos; |     lfs2_file_seek(&lfs2, &file, pos, LFS2_SEEK_SET) => pos; | ||||||
|     lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], pos, LFS2_SEEK_SET) => pos; |     lfs2_file_seek(&lfs2, &file, pos, LFS2_SEEK_SET) => pos; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "doggodogdog", size) => 0; |     memcmp(buffer, "doggodogdog", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_rewind(&lfs2, &file[0]) => 0; |     lfs2_file_rewind(&lfs2, &file) => 0; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], pos, LFS2_SEEK_SET) => pos; |     lfs2_file_seek(&lfs2, &file, pos, LFS2_SEEK_SET) => pos; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "doggodogdog", size) => 0; |     memcmp(buffer, "doggodogdog", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], -size, LFS2_SEEK_END) >= 0 => 1; |     lfs2_file_seek(&lfs2, &file, -size, LFS2_SEEK_END) >= 0 => 1; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "kittycatcat", size) => 0; |     memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|     size = lfs2_file_size(&lfs2, &file[0]); |     size = lfs2_file_size(&lfs2, &file); | ||||||
|     lfs2_file_seek(&lfs2, &file[0], 0, LFS2_SEEK_CUR) => size; |     lfs2_file_seek(&lfs2, &file, 0, LFS2_SEEK_CUR) => size; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Boundary seek and write ---" | echo "--- Boundary seek and write ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "hello/kitty042", LFS2_O_RDWR) => 0; |     lfs2_file_open(&lfs2, &file, "hello/kitty042", LFS2_O_RDWR) => 0; | ||||||
|  |  | ||||||
|     size = strlen("hedgehoghog"); |     lfs2_size_t size = strlen("hedgehoghog"); | ||||||
|     const lfs2_soff_t offsets[] = {512, 1020, 513, 1021, 511, 1019}; |     const lfs2_soff_t offsets[] = {512, 1020, 513, 1021, 511, 1019}; | ||||||
|  |  | ||||||
|     for (unsigned i = 0; i < sizeof(offsets) / sizeof(offsets[0]); i++) { |     for (unsigned i = 0; i < sizeof(offsets) / sizeof(offsets[0]); i++) { | ||||||
|         lfs2_soff_t off = offsets[i]; |         lfs2_soff_t off = offsets[i]; | ||||||
|         memcpy(buffer, "hedgehoghog", size); |         memcpy(buffer, "hedgehoghog", size); | ||||||
|         lfs2_file_seek(&lfs2, &file[0], off, LFS2_SEEK_SET) => off; |         lfs2_file_seek(&lfs2, &file, off, LFS2_SEEK_SET) => off; | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|         lfs2_file_seek(&lfs2, &file[0], off, LFS2_SEEK_SET) => off; |         lfs2_file_seek(&lfs2, &file, off, LFS2_SEEK_SET) => off; | ||||||
|         lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|         memcmp(buffer, "hedgehoghog", size) => 0; |         memcmp(buffer, "hedgehoghog", size) => 0; | ||||||
|  |  | ||||||
|         lfs2_file_seek(&lfs2, &file[0], 0, LFS2_SEEK_SET) => 0; |         lfs2_file_seek(&lfs2, &file, 0, LFS2_SEEK_SET) => 0; | ||||||
|         lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|         memcmp(buffer, "kittycatcat", size) => 0; |         memcmp(buffer, "kittycatcat", size) => 0; | ||||||
|  |  | ||||||
|         lfs2_file_sync(&lfs2, &file[0]) => 0; |         lfs2_file_sync(&lfs2, &file) => 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Out-of-bounds seek ---" | echo "--- Out-of-bounds seek ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "hello/kitty042", LFS2_O_RDWR) => 0; |     lfs2_file_open(&lfs2, &file, "hello/kitty042", LFS2_O_RDWR) => 0; | ||||||
|  |  | ||||||
|     size = strlen("kittycatcat"); |     lfs2_size_t size = strlen("kittycatcat"); | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $LARGESIZE*size; |     lfs2_file_size(&lfs2, &file) => $LARGESIZE*size; | ||||||
|     lfs2_file_seek(&lfs2, &file[0], ($LARGESIZE+$SMALLSIZE)*size, |     lfs2_file_seek(&lfs2, &file, ($LARGESIZE+$SMALLSIZE)*size, | ||||||
|             LFS2_SEEK_SET) => ($LARGESIZE+$SMALLSIZE)*size; |             LFS2_SEEK_SET) => ($LARGESIZE+$SMALLSIZE)*size; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => 0; |     lfs2_file_read(&lfs2, &file, buffer, size) => 0; | ||||||
|  |  | ||||||
|     memcpy(buffer, "porcupineee", size); |     memcpy(buffer, "porcupineee", size); | ||||||
|     lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], ($LARGESIZE+$SMALLSIZE)*size, |     lfs2_file_seek(&lfs2, &file, ($LARGESIZE+$SMALLSIZE)*size, | ||||||
|             LFS2_SEEK_SET) => ($LARGESIZE+$SMALLSIZE)*size; |             LFS2_SEEK_SET) => ($LARGESIZE+$SMALLSIZE)*size; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "porcupineee", size) => 0; |     memcmp(buffer, "porcupineee", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], $LARGESIZE*size, |     lfs2_file_seek(&lfs2, &file, $LARGESIZE*size, | ||||||
|             LFS2_SEEK_SET) => $LARGESIZE*size; |             LFS2_SEEK_SET) => $LARGESIZE*size; | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |     lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|     memcmp(buffer, "\0\0\0\0\0\0\0\0\0\0\0", size) => 0; |     memcmp(buffer, "\0\0\0\0\0\0\0\0\0\0\0", size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], -(($LARGESIZE+$SMALLSIZE)*size), |     lfs2_file_seek(&lfs2, &file, -(($LARGESIZE+$SMALLSIZE)*size), | ||||||
|             LFS2_SEEK_CUR) => LFS2_ERR_INVAL; |             LFS2_SEEK_CUR) => LFS2_ERR_INVAL; | ||||||
|     lfs2_file_tell(&lfs2, &file[0]) => ($LARGESIZE+1)*size; |     lfs2_file_tell(&lfs2, &file) => ($LARGESIZE+1)*size; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], -(($LARGESIZE+2*$SMALLSIZE)*size), |     lfs2_file_seek(&lfs2, &file, -(($LARGESIZE+2*$SMALLSIZE)*size), | ||||||
|             LFS2_SEEK_END) => LFS2_ERR_INVAL; |             LFS2_SEEK_END) => LFS2_ERR_INVAL; | ||||||
|     lfs2_file_tell(&lfs2, &file[0]) => ($LARGESIZE+1)*size; |     lfs2_file_tell(&lfs2, &file) => ($LARGESIZE+1)*size; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Inline write and seek ---" | echo "--- Inline write and seek ---" | ||||||
| for SIZE in $SMALLSIZE $MEDIUMSIZE $LARGESIZE | for SIZE in $SMALLSIZE $MEDIUMSIZE $LARGESIZE | ||||||
| do | do | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "hello/tinykitty$SIZE", |     lfs2_file_open(&lfs2, &file, "hello/tinykitty$SIZE", | ||||||
|             LFS2_O_RDWR | LFS2_O_CREAT) => 0; |             LFS2_O_RDWR | LFS2_O_CREAT) => 0; | ||||||
|     int j = 0; |     int j = 0; | ||||||
|     int k = 0; |     int k = 0; | ||||||
|  |  | ||||||
|     memcpy(buffer, "abcdefghijklmnopqrstuvwxyz", 26); |     memcpy(buffer, "abcdefghijklmnopqrstuvwxyz", 26); | ||||||
|     for (unsigned i = 0; i < $SIZE; i++) { |     for (unsigned i = 0; i < $SIZE; i++) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], &buffer[j++ % 26], 1) => 1; |         lfs2_file_write(&lfs2, &file, &buffer[j++ % 26], 1) => 1; | ||||||
|         lfs2_file_tell(&lfs2, &file[0]) => i+1; |         lfs2_file_tell(&lfs2, &file) => i+1; | ||||||
|         lfs2_file_size(&lfs2, &file[0]) => i+1; |         lfs2_file_size(&lfs2, &file) => i+1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], 0, LFS2_SEEK_SET) => 0; |     lfs2_file_seek(&lfs2, &file, 0, LFS2_SEEK_SET) => 0; | ||||||
|     lfs2_file_tell(&lfs2, &file[0]) => 0; |     lfs2_file_tell(&lfs2, &file) => 0; | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $SIZE; |     lfs2_file_size(&lfs2, &file) => $SIZE; | ||||||
|     for (unsigned i = 0; i < $SIZE; i++) { |     for (unsigned i = 0; i < $SIZE; i++) { | ||||||
|         uint8_t c; |         uint8_t c; | ||||||
|         lfs2_file_read(&lfs2, &file[0], &c, 1) => 1; |         lfs2_file_read(&lfs2, &file, &c, 1) => 1; | ||||||
|         c => buffer[k++ % 26]; |         c => buffer[k++ % 26]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_file_sync(&lfs2, &file[0]) => 0; |     lfs2_file_sync(&lfs2, &file) => 0; | ||||||
|     lfs2_file_tell(&lfs2, &file[0]) => $SIZE; |     lfs2_file_tell(&lfs2, &file) => $SIZE; | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $SIZE; |     lfs2_file_size(&lfs2, &file) => $SIZE; | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], 0, LFS2_SEEK_SET) => 0; |     lfs2_file_seek(&lfs2, &file, 0, LFS2_SEEK_SET) => 0; | ||||||
|     for (unsigned i = 0; i < $SIZE; i++) { |     for (unsigned i = 0; i < $SIZE; i++) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], &buffer[j++ % 26], 1) => 1; |         lfs2_file_write(&lfs2, &file, &buffer[j++ % 26], 1) => 1; | ||||||
|         lfs2_file_tell(&lfs2, &file[0]) => i+1; |         lfs2_file_tell(&lfs2, &file) => i+1; | ||||||
|         lfs2_file_size(&lfs2, &file[0]) => $SIZE; |         lfs2_file_size(&lfs2, &file) => $SIZE; | ||||||
|         lfs2_file_sync(&lfs2, &file[0]) => 0; |         lfs2_file_sync(&lfs2, &file) => 0; | ||||||
|         lfs2_file_tell(&lfs2, &file[0]) => i+1; |         lfs2_file_tell(&lfs2, &file) => i+1; | ||||||
|         lfs2_file_size(&lfs2, &file[0]) => $SIZE; |         lfs2_file_size(&lfs2, &file) => $SIZE; | ||||||
|         if (i < $SIZE-2) { |         if (i < $SIZE-2) { | ||||||
|             uint8_t c[3]; |             uint8_t c[3]; | ||||||
|             lfs2_file_seek(&lfs2, &file[0], -1, LFS2_SEEK_CUR) => i; |             lfs2_file_seek(&lfs2, &file, -1, LFS2_SEEK_CUR) => i; | ||||||
|             lfs2_file_read(&lfs2, &file[0], &c, 3) => 3; |             lfs2_file_read(&lfs2, &file, &c, 3) => 3; | ||||||
|             lfs2_file_tell(&lfs2, &file[0]) => i+3; |             lfs2_file_tell(&lfs2, &file) => i+3; | ||||||
|             lfs2_file_size(&lfs2, &file[0]) => $SIZE; |             lfs2_file_size(&lfs2, &file) => $SIZE; | ||||||
|             lfs2_file_seek(&lfs2, &file[0], i+1, LFS2_SEEK_SET) => i+1; |             lfs2_file_seek(&lfs2, &file, i+1, LFS2_SEEK_SET) => i+1; | ||||||
|             lfs2_file_tell(&lfs2, &file[0]) => i+1; |             lfs2_file_tell(&lfs2, &file) => i+1; | ||||||
|             lfs2_file_size(&lfs2, &file[0]) => $SIZE; |             lfs2_file_size(&lfs2, &file) => $SIZE; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_file_seek(&lfs2, &file[0], 0, LFS2_SEEK_SET) => 0; |     lfs2_file_seek(&lfs2, &file, 0, LFS2_SEEK_SET) => 0; | ||||||
|     lfs2_file_tell(&lfs2, &file[0]) => 0; |     lfs2_file_tell(&lfs2, &file) => 0; | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $SIZE; |     lfs2_file_size(&lfs2, &file) => $SIZE; | ||||||
|     for (unsigned i = 0; i < $SIZE; i++) { |     for (unsigned i = 0; i < $SIZE; i++) { | ||||||
|         uint8_t c; |         uint8_t c; | ||||||
|         lfs2_file_read(&lfs2, &file[0], &c, 1) => 1; |         lfs2_file_read(&lfs2, &file, &c, 1) => 1; | ||||||
|         c => buffer[k++ % 26]; |         c => buffer[k++ % 26]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_file_sync(&lfs2, &file[0]) => 0; |     lfs2_file_sync(&lfs2, &file) => 0; | ||||||
|     lfs2_file_tell(&lfs2, &file[0]) => $SIZE; |     lfs2_file_tell(&lfs2, &file) => $SIZE; | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $SIZE; |     lfs2_file_size(&lfs2, &file) => $SIZE; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| done | done | ||||||
|  |  | ||||||
| echo "--- Results ---" | scripts/results.py | ||||||
| tests/stats.py |  | ||||||
|   | |||||||
| @@ -1,156 +1,159 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| set -eu | set -eu | ||||||
|  | export TEST_FILE=$0 | ||||||
|  | trap 'export TEST_LINE=$LINENO' DEBUG | ||||||
|  |  | ||||||
|  | echo "=== Truncate tests ===" | ||||||
|  |  | ||||||
| SMALLSIZE=32 | SMALLSIZE=32 | ||||||
| MEDIUMSIZE=2048 | MEDIUMSIZE=2048 | ||||||
| LARGESIZE=8192 | LARGESIZE=8192 | ||||||
|  |  | ||||||
| echo "=== Truncate tests ===" |  | ||||||
| rm -rf blocks | rm -rf blocks | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_format(&lfs2, &cfg) => 0; |     lfs2_format(&lfs2, &cfg) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Simple truncate ---" | echo "--- Simple truncate ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "baldynoop", |     lfs2_file_open(&lfs2, &file, "baldynoop", | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|  |  | ||||||
|     strcpy((char*)buffer, "hair"); |     strcpy((char*)buffer, "hair"); | ||||||
|     size = strlen((char*)buffer); |     lfs2_size_t size = strlen((char*)buffer); | ||||||
|     for (lfs2_off_t j = 0; j < $LARGESIZE; j += size) { |     for (lfs2_off_t j = 0; j < $LARGESIZE; j += size) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $LARGESIZE; |     lfs2_file_size(&lfs2, &file) => $LARGESIZE; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "baldynoop", LFS2_O_RDWR) => 0; |     lfs2_file_open(&lfs2, &file, "baldynoop", LFS2_O_RDWR) => 0; | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $LARGESIZE; |     lfs2_file_size(&lfs2, &file) => $LARGESIZE; | ||||||
|  |  | ||||||
|     lfs2_file_truncate(&lfs2, &file[0], $MEDIUMSIZE) => 0; |     lfs2_file_truncate(&lfs2, &file, $MEDIUMSIZE) => 0; | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $MEDIUMSIZE; |     lfs2_file_size(&lfs2, &file) => $MEDIUMSIZE; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "baldynoop", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &file, "baldynoop", LFS2_O_RDONLY) => 0; | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $MEDIUMSIZE; |     lfs2_file_size(&lfs2, &file) => $MEDIUMSIZE; | ||||||
|  |  | ||||||
|     size = strlen("hair"); |     lfs2_size_t size = strlen("hair"); | ||||||
|     for (lfs2_off_t j = 0; j < $MEDIUMSIZE; j += size) { |     for (lfs2_off_t j = 0; j < $MEDIUMSIZE; j += size) { | ||||||
|         lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|         memcmp(buffer, "hair", size) => 0; |         memcmp(buffer, "hair", size) => 0; | ||||||
|     } |     } | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => 0; |     lfs2_file_read(&lfs2, &file, buffer, size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Truncate and read ---" | echo "--- Truncate and read ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "baldyread", |     lfs2_file_open(&lfs2, &file, "baldyread", | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|  |  | ||||||
|     strcpy((char*)buffer, "hair"); |     strcpy((char*)buffer, "hair"); | ||||||
|     size = strlen((char*)buffer); |     lfs2_size_t size = strlen((char*)buffer); | ||||||
|     for (lfs2_off_t j = 0; j < $LARGESIZE; j += size) { |     for (lfs2_off_t j = 0; j < $LARGESIZE; j += size) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $LARGESIZE; |     lfs2_file_size(&lfs2, &file) => $LARGESIZE; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "baldyread", LFS2_O_RDWR) => 0; |     lfs2_file_open(&lfs2, &file, "baldyread", LFS2_O_RDWR) => 0; | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $LARGESIZE; |     lfs2_file_size(&lfs2, &file) => $LARGESIZE; | ||||||
|  |  | ||||||
|     lfs2_file_truncate(&lfs2, &file[0], $MEDIUMSIZE) => 0; |     lfs2_file_truncate(&lfs2, &file, $MEDIUMSIZE) => 0; | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $MEDIUMSIZE; |     lfs2_file_size(&lfs2, &file) => $MEDIUMSIZE; | ||||||
|  |  | ||||||
|     size = strlen("hair"); |     lfs2_size_t size = strlen("hair"); | ||||||
|     for (lfs2_off_t j = 0; j < $MEDIUMSIZE; j += size) { |     for (lfs2_off_t j = 0; j < $MEDIUMSIZE; j += size) { | ||||||
|         lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|         memcmp(buffer, "hair", size) => 0; |         memcmp(buffer, "hair", size) => 0; | ||||||
|     } |     } | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => 0; |     lfs2_file_read(&lfs2, &file, buffer, size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "baldyread", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &file, "baldyread", LFS2_O_RDONLY) => 0; | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $MEDIUMSIZE; |     lfs2_file_size(&lfs2, &file) => $MEDIUMSIZE; | ||||||
|  |  | ||||||
|     size = strlen("hair"); |     lfs2_size_t size = strlen("hair"); | ||||||
|     for (lfs2_off_t j = 0; j < $MEDIUMSIZE; j += size) { |     for (lfs2_off_t j = 0; j < $MEDIUMSIZE; j += size) { | ||||||
|         lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|         memcmp(buffer, "hair", size) => 0; |         memcmp(buffer, "hair", size) => 0; | ||||||
|     } |     } | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => 0; |     lfs2_file_read(&lfs2, &file, buffer, size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| echo "--- Truncate and write ---" | echo "--- Truncate and write ---" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "baldywrite", |     lfs2_file_open(&lfs2, &file, "baldywrite", | ||||||
|             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; |             LFS2_O_WRONLY | LFS2_O_CREAT) => 0; | ||||||
|  |  | ||||||
|     strcpy((char*)buffer, "hair"); |     strcpy((char*)buffer, "hair"); | ||||||
|     size = strlen((char*)buffer); |     lfs2_size_t size = strlen((char*)buffer); | ||||||
|     for (lfs2_off_t j = 0; j < $LARGESIZE; j += size) { |     for (lfs2_off_t j = 0; j < $LARGESIZE; j += size) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $LARGESIZE; |     lfs2_file_size(&lfs2, &file) => $LARGESIZE; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "baldywrite", LFS2_O_RDWR) => 0; |     lfs2_file_open(&lfs2, &file, "baldywrite", LFS2_O_RDWR) => 0; | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $LARGESIZE; |     lfs2_file_size(&lfs2, &file) => $LARGESIZE; | ||||||
|  |  | ||||||
|     lfs2_file_truncate(&lfs2, &file[0], $MEDIUMSIZE) => 0; |     lfs2_file_truncate(&lfs2, &file, $MEDIUMSIZE) => 0; | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $MEDIUMSIZE; |     lfs2_file_size(&lfs2, &file) => $MEDIUMSIZE; | ||||||
|  |  | ||||||
|     strcpy((char*)buffer, "bald"); |     strcpy((char*)buffer, "bald"); | ||||||
|     size = strlen((char*)buffer); |     lfs2_size_t size = strlen((char*)buffer); | ||||||
|     for (lfs2_off_t j = 0; j < $MEDIUMSIZE; j += size) { |     for (lfs2_off_t j = 0; j < $MEDIUMSIZE; j += size) { | ||||||
|         lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|     } |     } | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $MEDIUMSIZE; |     lfs2_file_size(&lfs2, &file) => $MEDIUMSIZE; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|     lfs2_file_open(&lfs2, &file[0], "baldywrite", LFS2_O_RDONLY) => 0; |     lfs2_file_open(&lfs2, &file, "baldywrite", LFS2_O_RDONLY) => 0; | ||||||
|     lfs2_file_size(&lfs2, &file[0]) => $MEDIUMSIZE; |     lfs2_file_size(&lfs2, &file) => $MEDIUMSIZE; | ||||||
|  |  | ||||||
|     size = strlen("bald"); |     lfs2_size_t size = strlen("bald"); | ||||||
|     for (lfs2_off_t j = 0; j < $MEDIUMSIZE; j += size) { |     for (lfs2_off_t j = 0; j < $MEDIUMSIZE; j += size) { | ||||||
|         lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |         lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|         memcmp(buffer, "bald", size) => 0; |         memcmp(buffer, "bald", size) => 0; | ||||||
|     } |     } | ||||||
|     lfs2_file_read(&lfs2, &file[0], buffer, size) => 0; |     lfs2_file_read(&lfs2, &file, buffer, size) => 0; | ||||||
|  |  | ||||||
|     lfs2_file_close(&lfs2, &file[0]) => 0; |     lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
|  |  | ||||||
| @@ -160,7 +163,7 @@ STARTSIZES="$1" | |||||||
| STARTSEEKS="$2" | STARTSEEKS="$2" | ||||||
| HOTSIZES="$3" | HOTSIZES="$3" | ||||||
| COLDSIZES="$4" | COLDSIZES="$4" | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     static const lfs2_off_t startsizes[] = {$STARTSIZES}; |     static const lfs2_off_t startsizes[] = {$STARTSIZES}; | ||||||
|     static const lfs2_off_t startseeks[] = {$STARTSEEKS}; |     static const lfs2_off_t startseeks[] = {$STARTSEEKS}; | ||||||
|     static const lfs2_off_t hotsizes[]   = {$HOTSIZES}; |     static const lfs2_off_t hotsizes[]   = {$HOTSIZES}; | ||||||
| @@ -168,31 +171,31 @@ tests/test.py << TEST | |||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     for (unsigned i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) { |     for (unsigned i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) { | ||||||
|         sprintf((char*)buffer, "hairyhead%d", i); |         sprintf(path, "hairyhead%d", i); | ||||||
|         lfs2_file_open(&lfs2, &file[0], (const char*)buffer, |         lfs2_file_open(&lfs2, &file, path, | ||||||
|                 LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_TRUNC) => 0; |                 LFS2_O_WRONLY | LFS2_O_CREAT | LFS2_O_TRUNC) => 0; | ||||||
|  |  | ||||||
|         strcpy((char*)buffer, "hair"); |         strcpy((char*)buffer, "hair"); | ||||||
|         size = strlen((char*)buffer); |         lfs2_size_t size = strlen((char*)buffer); | ||||||
|         for (lfs2_off_t j = 0; j < startsizes[i]; j += size) { |         for (lfs2_off_t j = 0; j < startsizes[i]; j += size) { | ||||||
|             lfs2_file_write(&lfs2, &file[0], buffer, size) => size; |             lfs2_file_write(&lfs2, &file, buffer, size) => size; | ||||||
|         } |         } | ||||||
|         lfs2_file_size(&lfs2, &file[0]) => startsizes[i]; |         lfs2_file_size(&lfs2, &file) => startsizes[i]; | ||||||
|  |  | ||||||
|         if (startseeks[i] != startsizes[i]) { |         if (startseeks[i] != startsizes[i]) { | ||||||
|             lfs2_file_seek(&lfs2, &file[0], |             lfs2_file_seek(&lfs2, &file, | ||||||
|                     startseeks[i], LFS2_SEEK_SET) => startseeks[i]; |                     startseeks[i], LFS2_SEEK_SET) => startseeks[i]; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         lfs2_file_truncate(&lfs2, &file[0], hotsizes[i]) => 0; |         lfs2_file_truncate(&lfs2, &file, hotsizes[i]) => 0; | ||||||
|         lfs2_file_size(&lfs2, &file[0]) => hotsizes[i]; |         lfs2_file_size(&lfs2, &file) => hotsizes[i]; | ||||||
|  |  | ||||||
|         lfs2_file_close(&lfs2, &file[0]) => 0; |         lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     static const lfs2_off_t startsizes[] = {$STARTSIZES}; |     static const lfs2_off_t startsizes[] = {$STARTSIZES}; | ||||||
|     static const lfs2_off_t hotsizes[]   = {$HOTSIZES}; |     static const lfs2_off_t hotsizes[]   = {$HOTSIZES}; | ||||||
|     static const lfs2_off_t coldsizes[]  = {$COLDSIZES}; |     static const lfs2_off_t coldsizes[]  = {$COLDSIZES}; | ||||||
| @@ -200,31 +203,31 @@ tests/test.py << TEST | |||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     for (unsigned i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) { |     for (unsigned i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) { | ||||||
|         sprintf((char*)buffer, "hairyhead%d", i); |         sprintf(path, "hairyhead%d", i); | ||||||
|         lfs2_file_open(&lfs2, &file[0], (const char*)buffer, LFS2_O_RDWR) => 0; |         lfs2_file_open(&lfs2, &file, path, LFS2_O_RDWR) => 0; | ||||||
|         lfs2_file_size(&lfs2, &file[0]) => hotsizes[i]; |         lfs2_file_size(&lfs2, &file) => hotsizes[i]; | ||||||
|  |  | ||||||
|         size = strlen("hair"); |         lfs2_size_t size = strlen("hair"); | ||||||
|         lfs2_off_t j = 0; |         lfs2_off_t j = 0; | ||||||
|         for (; j < startsizes[i] && j < hotsizes[i]; j += size) { |         for (; j < startsizes[i] && j < hotsizes[i]; j += size) { | ||||||
|             lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |             lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|             memcmp(buffer, "hair", size) => 0; |             memcmp(buffer, "hair", size) => 0; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         for (; j < hotsizes[i]; j += size) { |         for (; j < hotsizes[i]; j += size) { | ||||||
|             lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |             lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|             memcmp(buffer, "\0\0\0\0", size) => 0; |             memcmp(buffer, "\0\0\0\0", size) => 0; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         lfs2_file_truncate(&lfs2, &file[0], coldsizes[i]) => 0; |         lfs2_file_truncate(&lfs2, &file, coldsizes[i]) => 0; | ||||||
|         lfs2_file_size(&lfs2, &file[0]) => coldsizes[i]; |         lfs2_file_size(&lfs2, &file) => coldsizes[i]; | ||||||
|  |  | ||||||
|         lfs2_file_close(&lfs2, &file[0]) => 0; |         lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| TEST | TEST | ||||||
| tests/test.py << TEST | scripts/test.py << TEST | ||||||
|     static const lfs2_off_t startsizes[] = {$STARTSIZES}; |     static const lfs2_off_t startsizes[] = {$STARTSIZES}; | ||||||
|     static const lfs2_off_t hotsizes[]   = {$HOTSIZES}; |     static const lfs2_off_t hotsizes[]   = {$HOTSIZES}; | ||||||
|     static const lfs2_off_t coldsizes[]  = {$COLDSIZES}; |     static const lfs2_off_t coldsizes[]  = {$COLDSIZES}; | ||||||
| @@ -232,24 +235,24 @@ tests/test.py << TEST | |||||||
|     lfs2_mount(&lfs2, &cfg) => 0; |     lfs2_mount(&lfs2, &cfg) => 0; | ||||||
|  |  | ||||||
|     for (unsigned i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) { |     for (unsigned i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) { | ||||||
|         sprintf((char*)buffer, "hairyhead%d", i); |         sprintf(path, "hairyhead%d", i); | ||||||
|         lfs2_file_open(&lfs2, &file[0], (const char*)buffer, LFS2_O_RDONLY) => 0; |         lfs2_file_open(&lfs2, &file, path, LFS2_O_RDONLY) => 0; | ||||||
|         lfs2_file_size(&lfs2, &file[0]) => coldsizes[i]; |         lfs2_file_size(&lfs2, &file) => coldsizes[i]; | ||||||
|  |  | ||||||
|         size = strlen("hair"); |         lfs2_size_t size = strlen("hair"); | ||||||
|         lfs2_off_t j = 0; |         lfs2_off_t j = 0; | ||||||
|         for (; j < startsizes[i] && j < hotsizes[i] && j < coldsizes[i]; |         for (; j < startsizes[i] && j < hotsizes[i] && j < coldsizes[i]; | ||||||
|                 j += size) { |                 j += size) { | ||||||
|             lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |             lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|             memcmp(buffer, "hair", size) => 0; |             memcmp(buffer, "hair", size) => 0; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         for (; j < coldsizes[i]; j += size) { |         for (; j < coldsizes[i]; j += size) { | ||||||
|             lfs2_file_read(&lfs2, &file[0], buffer, size) => size; |             lfs2_file_read(&lfs2, &file, buffer, size) => size; | ||||||
|             memcmp(buffer, "\0\0\0\0", size) => 0; |             memcmp(buffer, "\0\0\0\0", size) => 0; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         lfs2_file_close(&lfs2, &file[0]) => 0; |         lfs2_file_close(&lfs2, &file) => 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     lfs2_unmount(&lfs2) => 0; |     lfs2_unmount(&lfs2) => 0; | ||||||
| @@ -298,5 +301,4 @@ truncate_test \ | |||||||
|     "2*$LARGESIZE, 2*$LARGESIZE, 2*$LARGESIZE, 2*$LARGESIZE, 2*$LARGESIZE" \ |     "2*$LARGESIZE, 2*$LARGESIZE, 2*$LARGESIZE, 2*$LARGESIZE, 2*$LARGESIZE" \ | ||||||
|     "2*$LARGESIZE, 2*$LARGESIZE, 2*$LARGESIZE, 2*$LARGESIZE, 2*$LARGESIZE" |     "2*$LARGESIZE, 2*$LARGESIZE, 2*$LARGESIZE, 2*$LARGESIZE, 2*$LARGESIZE" | ||||||
|  |  | ||||||
| echo "--- Results ---" | scripts/results.py | ||||||
| tests/stats.py |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user