From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yang Xu Date: Thu, 22 Oct 2020 14:22:39 +0800 Subject: [LTP] Broken Fedora build In-Reply-To: References: <20201021193547.GA49488@x230> <5F90F214.20102@cn.fujitsu.com> <5F91163D.9030307@cn.fujitsu.com> Message-ID: <5F91252F.3040504@cn.fujitsu.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ltp@lists.linux.it Hi Li > Xiao Yang wrote: > >>>> I prefer to go replace ftime() by gettimeofday() or clock_gettime() >>>> way to solve this from root. >>> +1 >>> >>> I have seen the hugetlb.c and trace_sched.c code, they all use the >>> time to generate a random value for ftok or sched_priority. So using >>> gettimeofday() also looks ok. >> Hi, >> >> It is fine for me to replace ftime(), but I wonder if we can remove >> fime() and srand()/srandom() directly? :-) >> It seems unnecessary to set the seed for random number. > > That's true, but random() will generate the same number each time. Agree. If we don't call srandom, repeatly call random binary will give same random num. ie root@localhost ~]# ./random random num 1804289383 random num 846930886 random num 1681692777 random num 1714636915 random num 1957747793 random num 424238335 random num 719885386 random num 1649760492 random num 596516649 random num 1189641421 [root@localhost ~]# ./random random num 1804289383 random num 846930886 random num 1681692777 random num 1714636915 random num 1957747793 random num 424238335 random num 719885386 random num 1649760492 random num 596516649 random num 1189641421 [root@localhost ~]# cat random.c #include #include void main(void) { int num,i; for (i=0;i<10;i++) { num =random(); printf("random num %d\n", num); } } [root@localhost ~]# So keep this maybe better. Best Regards Yang Xu > I slightly tend to keep setting the seed by srandom() to get a different > randomized number for test variety. >