diff options
| -rw-r--r-- | tools/testing/selftests/efivarfs/Makefile | 2 | ||||
| -rw-r--r-- | tools/testing/selftests/efivarfs/create-read.c | 38 | ||||
| -rw-r--r-- | tools/testing/selftests/efivarfs/efivarfs.sh | 7 |
3 files changed, 46 insertions, 1 deletions
diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile index b64f61467e26..29e8c6bc81b0 100644 --- a/tools/testing/selftests/efivarfs/Makefile +++ b/tools/testing/selftests/efivarfs/Makefile | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | CC = $(CROSS_COMPILE)gcc | 1 | CC = $(CROSS_COMPILE)gcc |
| 2 | CFLAGS = -Wall | 2 | CFLAGS = -Wall |
| 3 | 3 | ||
| 4 | test_objs = open-unlink | 4 | test_objs = open-unlink create-read |
| 5 | 5 | ||
| 6 | all: $(test_objs) | 6 | all: $(test_objs) |
| 7 | 7 | ||
diff --git a/tools/testing/selftests/efivarfs/create-read.c b/tools/testing/selftests/efivarfs/create-read.c new file mode 100644 index 000000000000..7feef1880968 --- /dev/null +++ b/tools/testing/selftests/efivarfs/create-read.c | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <stdint.h> | ||
| 3 | #include <stdlib.h> | ||
| 4 | #include <unistd.h> | ||
| 5 | #include <sys/types.h> | ||
| 6 | #include <sys/stat.h> | ||
| 7 | #include <fcntl.h> | ||
| 8 | #include <errno.h> | ||
| 9 | #include <string.h> | ||
| 10 | |||
| 11 | int main(int argc, char **argv) | ||
| 12 | { | ||
| 13 | const char *path; | ||
| 14 | char buf[4]; | ||
| 15 | int fd, rc; | ||
| 16 | |||
| 17 | if (argc < 2) { | ||
| 18 | fprintf(stderr, "usage: %s <path>\n", argv[0]); | ||
| 19 | return EXIT_FAILURE; | ||
| 20 | } | ||
| 21 | |||
| 22 | path = argv[1]; | ||
| 23 | |||
| 24 | /* create a test variable */ | ||
| 25 | fd = open(path, O_RDWR | O_CREAT, 0600); | ||
| 26 | if (fd < 0) { | ||
| 27 | perror("open(O_WRONLY)"); | ||
| 28 | return EXIT_FAILURE; | ||
| 29 | } | ||
| 30 | |||
| 31 | rc = read(fd, buf, sizeof(buf)); | ||
| 32 | if (rc != 0) { | ||
| 33 | fprintf(stderr, "Reading a new var should return EOF\n"); | ||
| 34 | return EXIT_FAILURE; | ||
| 35 | } | ||
| 36 | |||
| 37 | return EXIT_SUCCESS; | ||
| 38 | } | ||
diff --git a/tools/testing/selftests/efivarfs/efivarfs.sh b/tools/testing/selftests/efivarfs/efivarfs.sh index 3af4b370e70d..880cdd5dc63f 100644 --- a/tools/testing/selftests/efivarfs/efivarfs.sh +++ b/tools/testing/selftests/efivarfs/efivarfs.sh | |||
| @@ -70,6 +70,12 @@ test_create_empty() | |||
| 70 | fi | 70 | fi |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | test_create_read() | ||
| 74 | { | ||
| 75 | local file=$efivarfs_mount/$FUNCNAME-$test_guid | ||
| 76 | ./create-read $file | ||
| 77 | } | ||
| 78 | |||
| 73 | test_delete() | 79 | test_delete() |
| 74 | { | 80 | { |
| 75 | local attrs='\x07\x00\x00\x00' | 81 | local attrs='\x07\x00\x00\x00' |
| @@ -125,6 +131,7 @@ rc=0 | |||
| 125 | 131 | ||
| 126 | run_test test_create | 132 | run_test test_create |
| 127 | run_test test_create_empty | 133 | run_test test_create_empty |
| 134 | run_test test_create_read | ||
| 128 | run_test test_delete | 135 | run_test test_delete |
| 129 | run_test test_zero_size_delete | 136 | run_test test_zero_size_delete |
| 130 | run_test test_open_unlink | 137 | run_test test_open_unlink |
