fixing option to let user pick saved test data filename, exit if ther… (#9242)

* fixing option to let user pick saved test data filename, exit if there are many os/variant combination for a single output filename

* fixing style issues

* Update save-test-data.php

* Update save-test-data.php
This commit is contained in:
tarik
2018-11-21 11:27:53 -08:00
committed by Tony Murray
parent c78f92a4c2
commit f91fca8072

View File

@@ -94,6 +94,15 @@ if ($os_name) {
$os_list = ModuleTestHelper::findOsWithData($modules);
}
if (isset($options['f'])) {
if (count($os_list) != 1) {
echo "Failed to create test data, -f/--file option can be used with one os/variant combination.\n";
echo "Multiple combinations (".count($os_list).") found.\n";
exit(1);
}
$output_file = $options['f'];
}
// Now use the saved data to update the saved database data
$snmpsim = new Snmpsim();
@@ -121,7 +130,9 @@ try {
update_os_cache(true); // Force update of OS Cache
$tester = new ModuleTestHelper($modules, $target_os, $target_variant);
if (!$no_save && !empty($output_file)) {
$tester->setJsonSavePath($output_file);
}
$test_data = $tester->generateTestData($snmpsim, $no_save);
if ($no_save) {