summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-10-01 12:27:35 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-10-01 12:52:00 +0800
commit9fbd73a208c9465b4bf9e2c80c7290b72e62ead1 (patch)
treea0e2899a65433c23105140ab8591b10c19325c32 /test
parentb86a7a0533c4d723ea940ac2071f845f165f832c (diff)
downloadtalos-petitboot-9fbd73a208c9465b4bf9e2c80c7290b72e62ead1.tar.gz
talos-petitboot-9fbd73a208c9465b4bf9e2c80c7290b72e62ead1.zip
discover: Add device_{request,release}_write
Add a pair of functions to the parser API to allow write access to the underlying device. We'll use this in the GRUB2 parser to implement environment persistence. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'test')
-rw-r--r--test/parser/utils.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/parser/utils.c b/test/parser/utils.c
index d1ced73..33efda8 100644
--- a/test/parser/utils.c
+++ b/test/parser/utils.c
@@ -186,6 +186,36 @@ int parser_request_file(struct discover_context *ctx,
return -1;
}
+int parser_replace_file(struct discover_context *ctx,
+ struct discover_device *dev, const char *filename,
+ char *buf, int len)
+{
+ struct parser_test *test = ctx->test_data;
+ struct test_file *f, *file;
+
+ list_for_each_entry(&test->files, f, list) {
+ if (f->dev != dev)
+ continue;
+ if (strcmp(f->name, filename))
+ continue;
+
+ file = f;
+ break;
+ }
+
+ if (!file) {
+ file = talloc_zero(test, struct test_file);
+ file->dev = dev;
+ file->name = filename;
+ list_add(&test->files, &file->list);
+ } else {
+ talloc_free(file->data);
+ }
+
+ file->data = talloc_memdup(test, buf, len);
+ file->size = len;
+ return 0;
+}
int test_run_parser(struct parser_test *test, const char *parser_name)
{
struct p_item* i;
OpenPOWER on IntegriCloud