diff options
author | Roland Grunberg <rgrunber@redhat.com> | 2009-09-23 13:46:05 -0400 |
---|---|---|
committer | Frank Ch. Eigler <fche@elastic.org> | 2009-09-23 14:04:26 -0400 |
commit | 09846ceb72c27dfe87f0b5c8d0a6296fc09bbc36 (patch) | |
tree | 7134c0eb69051baf563a474048c7096bcc7dcfa4 /testsuite/systemtap.base/rand.stp | |
parent | dc0c46f5f74a9e0468236b31c8d9364eb24c3624 (diff) | |
download | systemtap-steved-09846ceb72c27dfe87f0b5c8d0a6296fc09bbc36.tar.gz systemtap-steved-09846ceb72c27dfe87f0b5c8d0a6296fc09bbc36.tar.xz systemtap-steved-09846ceb72c27dfe87f0b5c8d0a6296fc09bbc36.zip |
PR10632: tapset: randint() function + tests
Diffstat (limited to 'testsuite/systemtap.base/rand.stp')
-rw-r--r-- | testsuite/systemtap.base/rand.stp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/testsuite/systemtap.base/rand.stp b/testsuite/systemtap.base/rand.stp new file mode 100644 index 00000000..aca80877 --- /dev/null +++ b/testsuite/systemtap.base/rand.stp @@ -0,0 +1,41 @@ +function checkStatus(status:long){ + if (status == 1){ + printf("%s\n","FAIL") + }else{ + printf("%s\n","PASS") + } +} + +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") + } + } + + 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) + + exit() +} |