Add IGMP, prepend_buffer/parse_buffer, split UDP header, discovery tests, test all
This commit is contained in:
@@ -356,15 +356,17 @@ func findTestDevice() (string, error) {
|
||||
|
||||
func cmdTestGroup(args []string) error {
|
||||
if len(args) < 1 {
|
||||
return fmt.Errorf("usage: picomap test <list|run> [args...]")
|
||||
return fmt.Errorf("usage: picomap test <list|run|all> [args...]")
|
||||
}
|
||||
switch args[0] {
|
||||
case "list":
|
||||
return cmdTestList(args[1:])
|
||||
case "run":
|
||||
return cmdTestRun(args[1:])
|
||||
case "all":
|
||||
return cmdTestAll(args[1:])
|
||||
default:
|
||||
return fmt.Errorf("usage: picomap test <list|run> [args...]")
|
||||
return fmt.Errorf("usage: picomap test <list|run|all> [args...]")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,6 +391,51 @@ func cmdTestList(_ []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func cmdTestAll(_ []string) error {
|
||||
dev, err := findTestDevice()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := client.NewSerial(dev, 10*time.Second)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer c.Close()
|
||||
|
||||
list, err := c.ListTests()
|
||||
if err != nil {
|
||||
return fmt.Errorf("remote: %w", err)
|
||||
}
|
||||
|
||||
log := slog.With("dev", dev)
|
||||
failed := 0
|
||||
for _, name := range list.Names {
|
||||
log.Info("running test", "name", name)
|
||||
result, err := c.Test(name)
|
||||
if err != nil {
|
||||
log.Error("error", "name", name, "err", err)
|
||||
failed++
|
||||
continue
|
||||
}
|
||||
for _, msg := range result.Messages {
|
||||
log.Info("remote", "name", name, "msg", msg)
|
||||
}
|
||||
if result.Pass {
|
||||
log.Info("PASS", "name", name)
|
||||
} else {
|
||||
log.Error("FAIL", "name", name)
|
||||
failed++
|
||||
}
|
||||
}
|
||||
if failed > 0 {
|
||||
log.Error("tests failed", "count", failed)
|
||||
os.Exit(1)
|
||||
}
|
||||
log.Info("all tests passed", "count", len(list.Names))
|
||||
return nil
|
||||
}
|
||||
|
||||
func cmdTestRun(args []string) error {
|
||||
if len(args) < 1 {
|
||||
return fmt.Errorf("usage: picomap test run <name>")
|
||||
|
||||
Reference in New Issue
Block a user