~sircmpwn/hare-dev

hare: rt/test: fix timespec diff calculation v1 SUPERSEDED

Kirill Primak: 2
 rt/test: fix timespec diff calculation
 rt/test: fix milliseconds formatting

 3 files changed, 16 insertions(+), 4 deletions(-)
#867660 alpine.yml success
#867661 freebsd.yml success
hare/patches: SUCCESS in 1m37s

[rt/test: fix timespec diff calculation][0] from [Kirill Primak][1]

[0]: https://lists.sr.ht/~sircmpwn/hare-dev/patches/36319
[1]: mailto:vyivel@eclair.cafe

✓ #867660 SUCCESS hare/patches/alpine.yml  https://builds.sr.ht/~sircmpwn/job/867660
✓ #867661 SUCCESS hare/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/867661
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/hare-dev/patches/36319/mbox | git am -3
Learn more about email & git

[PATCH hare 1/2] rt/test: fix timespec diff calculation Export this patch

Signed-off-by: Kirill Primak <vyivel@eclair.cafe>
---
 rt/+test/+freebsd.ha | 9 +++++++--
 rt/+test/+linux.ha   | 9 +++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/rt/+test/+freebsd.ha b/rt/+test/+freebsd.ha
index e815bea2..6d31844a 100644
--- a/rt/+test/+freebsd.ha
+++ b/rt/+test/+freebsd.ha
@@ -11,6 +11,11 @@ fn time_start() void = {
fn time_stop() (size, size) = {
	let end: timespec = timespec { ... };
	clock_gettime(CLOCK_MONOTONIC, &end) as void;
	return ((end.tv_sec - start.tv_sec): size,
		(end.tv_nsec - start.tv_nsec): size / 10000z);
	let sec_diff = end.tv_sec - start.tv_sec;
	let nsec_diff = end.tv_nsec - start.tv_nsec;
	if (nsec_diff < 0) {
		nsec_diff += 1000000000;
		sec_diff -= 1;
	};
	return (sec_diff: size, nsec_diff: size / 1000000z);
};
diff --git a/rt/+test/+linux.ha b/rt/+test/+linux.ha
index 89b0fe41..ff5c2424 100644
--- a/rt/+test/+linux.ha
+++ b/rt/+test/+linux.ha
@@ -12,6 +12,11 @@ fn time_start() void = {
fn time_stop() (size, size) = {
	let end: timespec = timespec { ... };
	clock_gettime(CLOCK_MONOTONIC, &end) as void;
	return ((end.tv_sec - start.tv_sec): size,
		(end.tv_nsec - start.tv_nsec): size / 10000z);
	let sec_diff = end.tv_sec - start.tv_sec;
	let nsec_diff = end.tv_nsec - start.tv_nsec;
	if (nsec_diff < 0) {
		nsec_diff += 1000000000;
		sec_diff -= 1;
	};
	return (sec_diff: size, nsec_diff: size / 1000000z);
};
-- 
2.38.1

[PATCH hare 2/2] rt/test: fix milliseconds formatting Export this patch

Pad milliseconds with zeroes; the number is guaranteed to be in [0, 999]
range so these two checks are enough.

Signed-off-by: Kirill Primak <vyivel@eclair.cafe>
---
 rt/+test/run.ha | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/rt/+test/run.ha b/rt/+test/run.ha
index 7e0635ea..e4ae62d1 100644
--- a/rt/+test/run.ha
+++ b/rt/+test/run.ha
@@ -89,6 +89,8 @@ export fn tests_main() size = {
	print(" tests completed in ");
	print(ztos(end.0));
	print(".");
	if (end.1 < 10) print("0");
	if (end.1 < 100) print("0");
	print(ztos(end.1));
	print("s\n");

-- 
2.38.1
hare/patches: SUCCESS in 1m37s

[rt/test: fix timespec diff calculation][0] from [Kirill Primak][1]

[0]: https://lists.sr.ht/~sircmpwn/hare-dev/patches/36319
[1]: mailto:vyivel@eclair.cafe

✓ #867660 SUCCESS hare/patches/alpine.yml  https://builds.sr.ht/~sircmpwn/job/867660
✓ #867661 SUCCESS hare/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/867661