From f91fca80723cc1c964ce5672eeff2464d59aa861 Mon Sep 17 00:00:00 2001 From: tarik Date: Wed, 21 Nov 2018 11:27:53 -0800 Subject: [PATCH] =?UTF-8?q?fixing=20option=20to=20let=20user=20pick=20save?= =?UTF-8?q?d=20test=20data=20filename,=20exit=20if=20ther=E2=80=A6=20(#924?= =?UTF-8?q?2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- scripts/save-test-data.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/save-test-data.php b/scripts/save-test-data.php index 2541f74473..06cd9aa7f6 100755 --- a/scripts/save-test-data.php +++ b/scripts/save-test-data.php @@ -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) {