summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/rust/TARGETS1
-rw-r--r--test/rust/cargo/TARGETS8
-rw-r--r--test/rust/cargo/circle/TARGETS13
-rw-r--r--test/rust/cargo/circle/test_circle_sampling.sh8
-rw-r--r--test/rust/cargo/circle/verify.py16
5 files changed, 46 insertions, 0 deletions
diff --git a/test/rust/TARGETS b/test/rust/TARGETS
index 713ff64..d62b2d3 100644
--- a/test/rust/TARGETS
+++ b/test/rust/TARGETS
@@ -3,6 +3,7 @@
, "tainted": ["test"]
, "dirs":
[ [["./", "hello", ""], "hello"]
+ , [["./", "cargo", ""], "cargo"]
]
}
}
diff --git a/test/rust/cargo/TARGETS b/test/rust/cargo/TARGETS
new file mode 100644
index 0000000..1552a32
--- /dev/null
+++ b/test/rust/cargo/TARGETS
@@ -0,0 +1,8 @@
+{ "":
+ { "type": "install"
+ , "tainted": ["test"]
+ , "dirs":
+ [ [["./", "circle", ""], "circle"]
+ ]
+ }
+}
diff --git a/test/rust/cargo/circle/TARGETS b/test/rust/cargo/circle/TARGETS
new file mode 100644
index 0000000..565bb37
--- /dev/null
+++ b/test/rust/cargo/circle/TARGETS
@@ -0,0 +1,13 @@
+{ "": {"type": "install", "tainted": ["test"], "deps": ["test-sampling"]}
+, "test-sampling":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["sampling"]
+ , "test": ["test_circle_sampling.sh"]
+ , "deps": ["sample", "verify.py"]
+ , "keep": ["sampled"]
+ }
+, "sample":
+ { "type": "install"
+ , "files": {"bin/sample": ["@", "cargo/circle", "", "circle_sampling"]}
+ }
+}
diff --git a/test/rust/cargo/circle/test_circle_sampling.sh b/test/rust/cargo/circle/test_circle_sampling.sh
new file mode 100644
index 0000000..c22109a
--- /dev/null
+++ b/test/rust/cargo/circle/test_circle_sampling.sh
@@ -0,0 +1,8 @@
+set -e
+
+for _ in `seq 1 100`
+do
+ ./bin/sample >> sampled
+done
+
+python3 verify.py sampled
diff --git a/test/rust/cargo/circle/verify.py b/test/rust/cargo/circle/verify.py
new file mode 100644
index 0000000..09dccee
--- /dev/null
+++ b/test/rust/cargo/circle/verify.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python3
+
+import math
+import sys
+
+with open(sys.argv[1]) as f:
+ samples = f.read()
+
+for line in samples.splitlines():
+ xs, ys = line.split()
+ x = int(xs)
+ y = int(ys)
+ radius = math.sqrt(x*x + y*y)
+ print ("(%+3d,%+3d) -> %4.1f" % (x,y,radius))
+ if radius > 100.0:
+ sys.exit(1)