summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base/rand.stp
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2009-09-23 16:41:40 -0400
committerFrank Ch. Eigler <fche@elastic.org>2009-09-23 16:41:40 -0400
commitd098276239dd9f2e1ad031b48519a5a21779c369 (patch)
tree9b288ad5fcf9ac9b7a13f3bdc986621230d60dc2 /testsuite/systemtap.base/rand.stp
parent09846ceb72c27dfe87f0b5c8d0a6296fc09bbc36 (diff)
downloadsystemtap-steved-d098276239dd9f2e1ad031b48519a5a21779c369.tar.gz
systemtap-steved-d098276239dd9f2e1ad031b48519a5a21779c369.tar.xz
systemtap-steved-d098276239dd9f2e1ad031b48519a5a21779c369.zip
PR10632: simplify randint() implementation
* tapset/random.stp (randint): Make it 1-arity (imply min=0). Document with kerneldoc. * doc/Systemtap_Tapset_Reference/tapsets.tmpl: Extract the docs. * runtime/arith.c (_stp_random_pm_u): Rename without _pm. (_stp_random_pm): Rewrite in terms of ..._u. * testsuite/random.stp: Adapt & simplify.
Diffstat (limited to 'testsuite/systemtap.base/rand.stp')
-rw-r--r--testsuite/systemtap.base/rand.stp32
1 files changed, 5 insertions, 27 deletions
diff --git a/testsuite/systemtap.base/rand.stp b/testsuite/systemtap.base/rand.stp
index aca80877..d584e5f7 100644
--- a/testsuite/systemtap.base/rand.stp
+++ b/testsuite/systemtap.base/rand.stp
@@ -8,34 +8,12 @@ function checkStatus(status:long){
probe begin
{
-
- for (i = 0; i < 100; i ++) {
- num = randint(-5, 5)
- if (num > 5) {
- printf("NUMBER TOO HIGH\n")
- }
- if (num < -5) {
- printf("NUMBER TOO LOW\n")
+ status = 0
+ for (i=1; i <= 100; i++){
+ if (randint(i) < 0 || randint(i) > i) {
+ status = 1
}
}
-
- for (i = 0; i < 500; i ++) {
- num = randint(-3, 3)
- if (num > 3) {
- printf("NUMBER TOO HIGH\n")
- }
- if (num < -3) {
- printf("NUMBER TOO LOW\n")
- }
- }
-
- status = 0
- for (i=1; i <= 100; i++){
- if ( randint(-1*i,i) < (-1*i) || randint(-1*i,i) > i ){
- status = 1
- }
- }
- checkStatus(status)
-
+ checkStatus(status)
exit()
}