]> xenbits.xensource.com Git - people/gdunlap/xsatool/commitdiff
main: Move 'systemtest' command outside of XsaMain
authorGeorge Dunlap <george.dunlap@citrix.com>
Fri, 27 Oct 2017 16:10:50 +0000 (17:10 +0100)
committerGeorge Dunlap <george.dunlap@citrix.com>
Fri, 27 Oct 2017 16:10:50 +0000 (17:10 +0100)
XsaMain() is meant to be called by systemtest; there's no sense in
being able to call systemtest via XsaMain.  Moving the test for
'systemtest' into main() allows us to get rid of systemtest
special-casing re argument counts.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
main.go

diff --git a/main.go b/main.go
index e090f21f06e6b949f96713586187c5258890d8ca..3c71c8476f1454164af63f9ced3d468d589b270c 100644 (file)
--- a/main.go
+++ b/main.go
@@ -82,7 +82,7 @@ func globalReset() {
 }
 
 func XsaMain(args []string) int {
-       if len(args) < 3 && args[1] != "systemtest" {
+       if len(args) < 3 {
                fmt.Printf("Not enough arguments\n")
                return 1
        }
@@ -99,18 +99,8 @@ func XsaMain(args []string) int {
        loadXSA := false
 
        tgt := args[1]
-       args = args[2:]
-
-       // Check for this first
-       if tgt == "systemtest" {
-               return MainSystemTest(args)
-       }
-
-       var cmd string
-       if len(args) > 0 {
-               cmd = args[0]
-               args = args[1:]
-       }
+       cmd := args[2]
+       args = args[3:]
 
        if xsanum, err = strconv.Atoi(tgt); err == nil {
                switch cmd {
@@ -249,6 +239,11 @@ func QuerySetResponses(responses []string) {
 }
 
 func main() {
+       // 'systemtest' isn't subject to system testing, so shouldn't be in XsaMain
+       if len(os.Args) > 1 && os.Args[1] == "systemtest" {
+               os.Exit(MainSystemTest(os.Args))
+       }
+       
        Q.real = true
        os.Exit(XsaMain(os.Args))
 }