From aaebb8f3abc10b4ef24a75a379db2e6fc91e68dc Mon Sep 17 00:00:00 2001 From: Ophestra Date: Fri, 14 Feb 2025 14:44:28 +0900 Subject: 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 --- main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 1ef11e1e..59e55928 100644 --- a/main.go +++ b/main.go @@ -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") } -- cgit v1.3.1