diff options
author | Mike Frysinger <vapier@chromium.org> | 2015-03-12 03:33:36 -0400 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-03-13 05:12:51 +0000 |
commit | cdf7dc949819833f96ee1ad3a607cad1deeff48a (patch) | |
tree | b4cc2c969626c8198f0c60bdc520307af0e7000f /tests/vb21_host_misc_tests.c | |
parent | 47c2aa0b71cabac1b50752a146cb2d8d4e0f304e (diff) | |
download | vboot-cdf7dc949819833f96ee1ad3a607cad1deeff48a.tar.gz |
vb21 tests: use the build dir for temp files
Rather than write to temp files in the cwd, use the existing build dir
as our scratch space. This lets us build out of tree properly even if
the source repo is read only.
BUG=chromium:466499
TEST=precq still passes
TEST=out-of-tree ebuild passes
BRANCH=None
Change-Id: I5dd69dcb8289cc557143e115e409b9c0924263b3
Reviewed-on: https://chromium-review.googlesource.com/259530
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Diffstat (limited to 'tests/vb21_host_misc_tests.c')
-rw-r--r-- | tests/vb21_host_misc_tests.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/vb21_host_misc_tests.c b/tests/vb21_host_misc_tests.c index 638977e2..125d0c36 100644 --- a/tests/vb21_host_misc_tests.c +++ b/tests/vb21_host_misc_tests.c @@ -5,6 +5,7 @@ * Tests for host misc library vboot2 functions */ +#include <stdio.h> #include <unistd.h> #include "2sysincludes.h" @@ -27,9 +28,9 @@ static void misc_tests(void) TEST_EQ(vb2_desc_size("foob"), 8, "desc size 'foob'"); } -static void file_tests(void) +static void file_tests(const char *temp_dir) { - const char *testfile = "file_tests.dat"; + char *testfile; const uint8_t test_data[] = "Some test data"; uint8_t *read_data; uint32_t read_size; @@ -37,6 +38,8 @@ static void file_tests(void) uint8_t cbuf[sizeof(struct vb2_struct_common) + 12]; struct vb2_struct_common *c = (struct vb2_struct_common *)cbuf; + xasprintf(&testfile, "%s/file_tests.dat", temp_dir); + unlink(testfile); TEST_EQ(vb2_read_file(testfile, &read_data, &read_size), @@ -70,8 +73,14 @@ static void file_tests(void) int main(int argc, char* argv[]) { + if (argc != 2) { + fprintf(stderr, "Usage: %s <temp_dir>\n", argv[0]); + return -1; + } + const char *temp_dir = argv[1]; + misc_tests(); - file_tests(); + file_tests(temp_dir); return gTestSuccess ? 0 : 255; } |