From d3c8fe89112fbaa9338ee52fff23eb47612769ce Mon Sep 17 00:00:00 2001 From: Dongsu Park Date: Tue, 23 Aug 2016 16:41:46 +0200 Subject: [PATCH] functional: exclude ActiveEnterTimestamp from unit comparison condition Actually it's not necessary to check that both units have the same value for ActiveEnterTimestamp, as it can vary at any time. So let's exclude ActiveEnterTimestamp from the condition for unit comparison. --- functional/systemd_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/functional/systemd_test.go b/functional/systemd_test.go index 9089cf707..cc884c1bd 100644 --- a/functional/systemd_test.go +++ b/functional/systemd_test.go @@ -119,8 +119,19 @@ func waitForUnitState(mgr unit.UnitManager, name string, want unit.UnitState) er return err } - if reflect.DeepEqual(want, *got) { + if isEqualUnitState(want, *got) { return nil } } } + +// isEqualUnitState checks if both units are the same, +// excluding ActiveEnterTimestamp field of each unit state. +func isEqualUnitState(src, dst unit.UnitState) bool { + return src.LoadState == dst.LoadState && + src.ActiveState == dst.ActiveState && + src.SubState == dst.SubState && + src.MachineID == dst.MachineID && + src.UnitHash == dst.UnitHash && + src.UnitName == dst.UnitName +}