From f6d0fa4cd08c3292a90c0a258bf46f79e1684a56 Mon Sep 17 00:00:00 2001 From: CismonX Date: Thu, 21 Jan 2021 03:42:21 +0800 Subject: [PATCH] Use system RNG in tests. --- tests/ctlseqs/match.exp | 6 +++--- tests/init.exp | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/ctlseqs/match.exp b/tests/ctlseqs/match.exp index 239c143..aedcf51 100644 --- a/tests/ctlseqs/match.exp +++ b/tests/ctlseqs/match.exp @@ -9,9 +9,9 @@ set tool ctlseqs set timeout 2 -set n1 [ expr int(rand()*5000) ] -set n2 [ expr int(rand()*5000) ] -set n3 [ expr int(rand()*5000) ] +set n1 [ random_int ] +set n2 [ random_int ] +set n3 [ random_int ] set input { } lappend input "$CSI$n1;${n2}H" diff --git a/tests/init.exp b/tests/init.exp index b3c1d1e..a047423 100644 --- a/tests/init.exp +++ b/tests/init.exp @@ -6,6 +6,11 @@ # this notice are preserved. This file is offered as-is, without any warranty. # +set ESC "\x1b" +set CSI "$ESC\[" +set DCS "${ESC}P" +set ST "$ESC\\" + proc tcsgrep_start args { global TCSGREP_BIN set run_cmd [ list $TCSGREP_BIN "-t500" ] @@ -38,7 +43,7 @@ proc tcsgrep_stop { } { } } -set ESC "\x1b" -set CSI "$ESC\[" -set DCS "${ESC}P" -set ST "$ESC\\" +proc random_int { } { + set num [ exec od -An -td -N4 /dev/urandom ] + return [ expr abs(int($num)) ] +}