tests: Changing `retcode` to contain the prompt
This is done to avoid prompt leftover in the `expect` buffer.
@@ -2879,7 +2879,7 @@ func configureIPv6OnVMI(vmi *v1.VirtualMachineInstance, expecter expect.Expecter
&expect.BSnd{S: "\n"},
&expect.BExp{R: prompt},
&expect.BSnd{S: "ip a | grep -q eth0; echo $?\n"},
- &expect.BExp{R: retcode("0")}})
+ &expect.BExp{R: Retcode("0", prompt)}})
_, err := ExpectBatchWithValidatedSend(expecter, hasNetEth0Batch, 30*time.Second)
return err == nil
}
@@ -2889,7 +2889,7 @@ func configureIPv6OnVMI(vmi *v1.VirtualMachineInstance, expecter expect.Expecter
&expect.BSnd{S: "\n"},
&expect.BExp{R: prompt},
&expect.BSnd{S: "ip -6 address show dev eth0 scope global | grep -q inet6; echo $?\n"},
- &expect.BExp{R: retcode("0")}})
+ &expect.BExp{R: Retcode("0", prompt)}})
_, err := ExpectBatchWithValidatedSend(expecter, hasGlobalIPv6Batch, 30*time.Second)
return err == nil
}
@@ -2912,7 +2912,7 @@ func configureIPv6OnVMI(vmi *v1.VirtualMachineInstance, expecter expect.Expecter
&expect.BSnd{S: "\n"},
&expect.BExp{R: prompt},
&expect.BSnd{S: "sudo ip -6 addr add fd10:0:2::2/120 dev eth0; echo $?\n"},
- &expect.BExp{R: retcode("0")}})
+ &expect.BExp{R: Retcode("0", prompt)}})
resp, err := ExpectBatchWithValidatedSend(expecter, addIPv6Address, 30*time.Second)
if err != nil {
log.DefaultLogger().Object(vmi).Infof("addIPv6Address failed: %v", resp)
@@ -2925,7 +2925,7 @@ func configureIPv6OnVMI(vmi *v1.VirtualMachineInstance, expecter expect.Expecter
&expect.BSnd{S: "\n"},
&expect.BExp{R: prompt},
&expect.BSnd{S: "sudo ip -6 route add default via fd10:0:2::1 src fd10:0:2::2; echo $?\n"},
- &expect.BExp{R: retcode("0")}})
+ &expect.BExp{R: Retcode("0", prompt)}})
resp, err = ExpectBatchWithValidatedSend(expecter, addIPv6DefaultRoute, 30*time.Second)
if err != nil {
log.DefaultLogger().Object(vmi).Infof("addIPv6DefaultRoute failed: %v", resp)
@@ -5032,6 +5032,6 @@ func IsLauncherCapabilityValid(capability k8sv1.Capability) bool {
return false
}
-func retcode(retcode string) string {
- return "\n" + retcode
+func Retcode(retcode string, prompt string) string {
+ return "\n" + retcode + "\r\n" + ".*" + prompt
}
