From: Jeremy Kerr <jk@ozlabs.org>
To: linux-kernel@vger.kernel.org
Cc: linux-efi@vger.kernel.org, Matt Fleming <matt.fleming@intel.com>,
Lingzhu Xiang <lxiang@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 3/3 v3] selftests/efivarfs: Add create-read test
Date: Wed, 06 Feb 2013 22:48:08 +0800 [thread overview]
Message-ID: <1360162088.143529.797155879961.3.gpush@pecola> (raw)
In-Reply-To: <1360162088.142733.191120808822.0.gpush@pecola>
Test that reads from a newly-created efivarfs file (with no data
written) will return EOF.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
---
tools/testing/selftests/efivarfs/Makefile | 2
tools/testing/selftests/efivarfs/create-read.c | 38 +++++++++++++++++
tools/testing/selftests/efivarfs/efivarfs.sh | 7 +++
3 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile
index 1a943ee..b4a7aca 100644
--- a/tools/testing/selftests/efivarfs/Makefile
+++ b/tools/testing/selftests/efivarfs/Makefile
@@ -1,7 +1,7 @@
CC = $(CROSS_COMPILE)gcc
CFLAGS = -Wall
-test_objs = open-unlink
+test_objs = open-unlink create-read
all: $(test_objs)
diff --git a/tools/testing/selftests/efivarfs/create-read.c b/tools/testing/selftests/efivarfs/create-read.c
new file mode 100644
index 0000000..7feef18
--- /dev/null
+++ b/tools/testing/selftests/efivarfs/create-read.c
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+
+int main(int argc, char **argv)
+{
+ const char *path;
+ char buf[4];
+ int fd, rc;
+
+ if (argc < 2) {
+ fprintf(stderr, "usage: %s <path>\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ path = argv[1];
+
+ /* create a test variable */
+ fd = open(path, O_RDWR | O_CREAT, 0600);
+ if (fd < 0) {
+ perror("open(O_WRONLY)");
+ return EXIT_FAILURE;
+ }
+
+ rc = read(fd, buf, sizeof(buf));
+ if (rc != 0) {
+ fprintf(stderr, "Reading a new var should return EOF\n");
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/tools/testing/selftests/efivarfs/efivarfs.sh b/tools/testing/selftests/efivarfs/efivarfs.sh
index 3af4b37..880cdd5 100755
--- a/tools/testing/selftests/efivarfs/efivarfs.sh
+++ b/tools/testing/selftests/efivarfs/efivarfs.sh
@@ -70,6 +70,12 @@ test_create_empty()
fi
}
+test_create_read()
+{
+ local file=$efivarfs_mount/$FUNCNAME-$test_guid
+ ./create-read $file
+}
+
test_delete()
{
local attrs='\x07\x00\x00\x00'
@@ -125,6 +131,7 @@ rc=0
run_test test_create
run_test test_create_empty
+run_test test_create_read
run_test test_delete
run_test test_zero_size_delete
run_test test_open_unlink
next prev parent reply other threads:[~2013-02-06 14:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-06 14:48 [PATCH 0/3 v3] selftests: Add efivarfs tests Jeremy Kerr
2013-02-06 14:48 ` Jeremy Kerr [this message]
2013-02-06 14:48 ` [PATCH 1/3 v3] selftests: Add tests for efivarfs Jeremy Kerr
2013-02-07 23:13 ` Andrew Morton
2013-02-08 10:02 ` [PATCH] Documentation: Add a simple doc for selftests Jeremy Kerr
2013-02-12 23:56 ` Andrew Morton
2013-02-08 10:05 ` [PATCH 1/3 v3] selftests: Add tests for efivarfs Jeremy Kerr
2013-02-08 10:08 ` Matt Fleming
2013-02-12 23:50 ` Andrew Morton
2013-02-13 7:32 ` Matt Fleming
2013-02-12 23:48 ` Andrew Morton
2013-02-06 14:48 ` [PATCH 2/3 v3] selftests/efivarfs: Add empty file creation test Jeremy Kerr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1360162088.143529.797155879961.3.gpush@pecola \
--to=jk@ozlabs.org \
--cc=akpm@linux-foundation.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lxiang@redhat.com \
--cc=matt.fleming@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®