diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-02-14 14:44:28 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-02-14 14:44:28 +0900 |
| commit | aaebb8f3abc10b4ef24a75a379db2e6fc91e68dc (patch) | |
| tree | d8bdd1b9f6f3b916efb95fcda97b070d24428c01 /main.go | |
| parent | 1f74b636d31e816907ff6adbf1472f9e0fb37ab7 (diff) | |
fortify: check print behaviour
These output are supposed to be deterministic, so checking them is a good way to catch regressions.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -13,6 +13,7 @@ import ( "sync" "syscall" "text/tabwriter" + "time" "git.gensokyo.uk/security/fortify/dbus" "git.gensokyo.uk/security/fortify/fst" @@ -23,6 +24,7 @@ import ( "git.gensokyo.uk/security/fortify/internal/linux" init0 "git.gensokyo.uk/security/fortify/internal/priv/init" "git.gensokyo.uk/security/fortify/internal/priv/shim" + "git.gensokyo.uk/security/fortify/internal/state" "git.gensokyo.uk/security/fortify/internal/system" ) @@ -114,7 +116,7 @@ func main() { fmt.Println(license) fmsg.Exit(0) case "template": // print full template configuration - printJSON(fst.Template()) + printJSON(os.Stdout, false, fst.Template()) fmsg.Exit(0) case "help": // print help message flag.CommandLine.Usage() @@ -127,7 +129,7 @@ func main() { // Ignore errors; set is set for ExitOnError. _ = set.Parse(args[1:]) - printPs(short) + printPs(os.Stdout, time.Now().UTC(), state.NewMulti(sys.Paths().RunDirPath), short) fmsg.Exit(0) case "show": // pretty-print app info set := flag.NewFlagSet("show", flag.ExitOnError) @@ -139,14 +141,14 @@ func main() { switch len(set.Args()) { case 0: // system - printShowSystem(short) + printShowSystem(os.Stdout, short) case 1: // instance name := set.Args()[0] config, instance := tryShort(name) if config == nil { config = tryPath(name) } - printShowInstance(instance, config, short) + printShowInstance(os.Stdout, time.Now().UTC(), instance, config, short) default: fmsg.Fatal("show requires 1 argument") } |
