From 4e244df873bb0cb0d549c91216d5475f132dea37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadej=20Jane=C5=BE?= Date: Tue, 14 Jul 2020 11:06:08 +0200 Subject: [PATCH] go/oasis-test-runner/cmd: Fail if parallel.job_index flag is invalid --- go/oasis-test-runner/cmd/root.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/go/oasis-test-runner/cmd/root.go b/go/oasis-test-runner/cmd/root.go index 9f15659c9f6..bf084e566bf 100644 --- a/go/oasis-test-runner/cmd/root.go +++ b/go/oasis-test-runner/cmd/root.go @@ -316,9 +316,15 @@ func runRoot(cmd *cobra.Command, args []string) error { } } - // Run the required test scenarios. + // Get parallel job execution parameters. parallelJobCount := viper.GetInt(cfgParallelJobCount) parallelJobIndex := viper.GetInt(cfgParallelJobIndex) + if parallelJobIndex < 0 || parallelJobIndex >= parallelJobCount { + return fmt.Errorf( + "root: invalid value of %s flag: %d (should be in range [0, %d))", + cfgParallelJobIndex, parallelJobIndex, parallelJobCount, + ) + } // Parse test parameters passed by CLI. var toRunExploded map[string][]scenario.Scenario