aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bbot/machine-manifest.cxx44
-rw-r--r--unit-tests/bootstrap-manifest/testscript71
2 files changed, 98 insertions, 17 deletions
diff --git a/bbot/machine-manifest.cxx b/bbot/machine-manifest.cxx
index 5cef054..2edf3dc 100644
--- a/bbot/machine-manifest.cxx
+++ b/bbot/machine-manifest.cxx
@@ -4,6 +4,7 @@
#include <bbot/machine-manifest>
+#include <butl/string-parser>
#include <butl/manifest-parser>
#include <butl/manifest-serializer>
@@ -62,9 +63,9 @@ namespace bbot
throw parsing (p.name (), nv.name_line, nv.name_column, d);
};
- auto bad_value = [&p, &nv] (const string& d)
+ auto bad_value = [&p, &nv] (const string& d, size_t offset = 0)
{
- throw parsing (p.name (), nv.value_line, nv.value_column, d);
+ throw parsing (p.name (), nv.value_line, nv.value_column + offset, d);
};
// Make sure this is the start and we support the version.
@@ -133,6 +134,28 @@ namespace bbot
mac = move (v);
}
+ else if (n == "options")
+ {
+ if (options)
+ bad_name ("machine options redefinition");
+
+ strings op;
+
+ try
+ {
+ op = string_parser::parse_quoted (v, false);
+ }
+ catch (const invalid_string& e)
+ {
+ bad_value (string ("invalid machine options: ") + e.what (),
+ e.position);
+ }
+
+ if (op.empty ())
+ bad_value ("empty machine options");
+
+ options = move (op);
+ }
else if (!iu)
bad_name ("unknown name '" + n + "' in machine manifest");
}
@@ -169,6 +192,23 @@ namespace bbot
if (mac)
s.next ("mac", *mac);
+ // Recompose options string as a space-separated option list,
+ //
+ if (options)
+ {
+ string v;
+ for (auto b (options->cbegin ()), i (b), e (options->cend ()); i != e;
+ ++i)
+ {
+ if (i != b)
+ v += ' ';
+
+ v += *i;
+ }
+
+ s.next ("options", v);
+ }
+
s.next ("", ""); // End of manifest.
}
diff --git a/unit-tests/bootstrap-manifest/testscript b/unit-tests/bootstrap-manifest/testscript
index 8e1fbcf..0632317 100644
--- a/unit-tests/bootstrap-manifest/testscript
+++ b/unit-tests/bootstrap-manifest/testscript
@@ -77,20 +77,42 @@
: valid
:
- $* <<EOF >>EOF
- : 1
- :
- id: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
- name: windows_10-msvc_14
- summary: Windows 10 build 1607 with VC 14 update 3
- type: kvm
- mac: de:ad:be:ef:de:ad
- :
- id: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
- :
- bbot-version: 1010200
- libbbot-version: 1010100
- EOF
+ {
+ : all-values
+ :
+ $* <<EOF >>EOF
+ : 1
+ :
+ id: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
+ name: windows_10-msvc_14
+ summary: Windows 10 build 1607 with VC 14 update 3
+ type: kvm
+ mac: de:ad:be:ef:de:ad
+ options: -device "virtio-scsi-pci,id=scsi" -device "scsi-hd,drive=disk0"
+ :
+ id: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
+ :
+ bbot-version: 1010200
+ libbbot-version: 1010100
+ EOF
+
+ : no-options
+ :
+ $* <<EOF >>EOF
+ : 1
+ :
+ id: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
+ name: windows_10-msvc_14
+ summary: Windows 10 build 1607 with VC 14 update 3
+ type: kvm
+ mac: de:ad:be:ef:de:ad
+ :
+ id: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
+ :
+ bbot-version: 1010200
+ libbbot-version: 1010100
+ EOF
+ }
: unknown
:
@@ -114,9 +136,28 @@
name: windows_10-msvc_14
summary: Windows 10 build 1607 with VC 14 update 3
type: kvm
-
EOI
+ : invalid-options
+ :
+ {
+ : unquoted
+ :
+ $* <<EOI 2>'stdin:3:42: error: invalid machine options: unterminated quoted string' == 1
+ : 1
+ :
+ options: -device "virtio-scsi-pci,id=scsi
+ EOI
+
+ : empty
+ :
+ $* <<EOI 2>'stdin:3:9: error: empty machine options' == 1
+ : 1
+ :
+ options:
+ EOI
+ }
+
: no-toolchain
:
$* <<EOI 2>'stdin:8:1: error: toolchain manifest expected' == 1