* [Buildroot] [PATCH 1/1] support/testing: add rrdtool runtime test
@ 2024-10-12 22:15 Julien Olivain
2024-10-31 19:52 ` Thomas Petazzoni via buildroot
2024-11-20 21:30 ` Peter Korsgaard
0 siblings, 2 replies; 3+ messages in thread
From: Julien Olivain @ 2024-10-12 22:15 UTC (permalink / raw)
To: buildroot; +Cc: Julien Olivain
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
Patch tested in:
https://gitlab.com/jolivain/buildroot/-/jobs/8070566041
---
DEVELOPERS | 1 +
support/testing/tests/package/test_rrdtool.py | 100 ++++++++++++++++++
2 files changed, 101 insertions(+)
create mode 100644 support/testing/tests/package/test_rrdtool.py
diff --git a/DEVELOPERS b/DEVELOPERS
index 44b1947487..e63e9c0ff3 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1981,6 +1981,7 @@ F: support/testing/tests/package/test_python_spake2.py
F: support/testing/tests/package/test_python_sympy.py
F: support/testing/tests/package/test_rdma_core.py
F: support/testing/tests/package/test_rdma_core/
+F: support/testing/tests/package/test_rrdtool.py
F: support/testing/tests/package/test_rt_tests.py
F: support/testing/tests/package/test_screen.py
F: support/testing/tests/package/test_sed.py
diff --git a/support/testing/tests/package/test_rrdtool.py b/support/testing/tests/package/test_rrdtool.py
new file mode 100644
index 0000000000..431a867bf2
--- /dev/null
+++ b/support/testing/tests/package/test_rrdtool.py
@@ -0,0 +1,100 @@
+import os
+
+import infra.basetest
+
+
+class TestRRDTool(infra.basetest.BRTest):
+ config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+ """
+ BR2_PACKAGE_RRDTOOL=y
+ BR2_PACKAGE_RRDTOOL_RRDGRAPH=y
+ BR2_TARGET_ROOTFS_CPIO=y
+ # BR2_TARGET_ROOTFS_TAR is not set
+ """
+
+ def test_run(self):
+ cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
+ self.emulator.boot(arch="armv5",
+ kernel="builtin",
+ options=["-initrd", cpio_file])
+ self.emulator.login()
+
+ # We check the program can run.
+ self.assertRunOk("rrdtool --version")
+
+ # This test sequence is inspired from parts of the RRDTool
+ # tutorial:
+ # https://oss.oetiker.ch/rrdtool/tut/rrdtutorial.en.html
+
+ rrd_file = "test.rrd"
+ data_source = "speed"
+
+ cmd = f"rrdtool create {rrd_file}"
+ cmd += " --start 920804400"
+ cmd += f" DS:{data_source}:COUNTER:600:U:U"
+ cmd += " RRA:AVERAGE:0.5:1:24"
+ cmd += " RRA:AVERAGE:0.5:6:10"
+ self.assertRunOk(cmd)
+
+ # Some data to fill in our database, from the tutorial page.
+ data = [12345, 12357, 12363, 12363, 12363,
+ 12373, 12383, 12393, 12399, 12405,
+ 12411, 12415, 12420, 12422, 12423]
+ timestamp = 920804700 # timestamp of: Sun Mar 7 12:05:00 PM CET 1999
+
+ # We check we can put our data in the database. We start at
+ # our timestamp, then increase by 5 minutes.
+ for d in data:
+ cmd = f"rrdtool update {rrd_file} {timestamp}:{d}"
+ timestamp += 300
+ self.assertRunOk(cmd)
+
+ # We check we can read back our data.
+ cmd = f"rrdtool fetch {rrd_file}"
+ cmd += " AVERAGE --start 920804400 --end 920809200"
+ out, ret = self.emulator.run(cmd)
+ self.assertEqual(ret, 0)
+ self.assertEqual(out[0].strip(), data_source)
+ # We check that at time=920805600 we have speed=0.
+ data_line = next(ln for ln in out if ln.strip().startswith('920805600:'))
+ speed = float(data_line.split(':')[1])
+ self.assertAlmostEqual(speed, 0.)
+
+ # We generate a first simple image graph.
+ cmd = "rrdtool graph speed.png"
+ cmd += " --start 920804400 --end 920808000"
+ cmd += f" DEF:myspeed={rrd_file}:{data_source}:AVERAGE"
+ cmd += " LINE2:myspeed#FF0000"
+ self.assertRunOk(cmd, timeout=20)
+
+ # We check the output file exists and has a size
+ # greater than zero.
+ self.assertRunOk("test -s speed.png")
+
+ # We generate a slightly more complex graph.
+ cmd = "rrdtool graph speed2.png"
+ cmd += " --start 920804400 --end 920808000"
+ cmd += " --vertical-label m/s"
+ cmd += f" DEF:myspeed={rrd_file}:{data_source}:AVERAGE"
+ cmd += " CDEF:realspeed=myspeed,1000,\\*"
+ cmd += " LINE2:realspeed#FF0000"
+ self.assertRunOk(cmd, timeout=20)
+
+ # Again, we check the output file exists.
+ self.assertRunOk("test -s speed2.png")
+
+ # Finally, we generate the last graph, with some rules.
+ cmd = "rrdtool graph speed3.png"
+ cmd += " --start 920804400 --end 920808000"
+ cmd += " --vertical-label km/h"
+ cmd += f" DEF:myspeed={rrd_file}:{data_source}:AVERAGE"
+ cmd += " \"CDEF:kmh=myspeed,3600,*\""
+ cmd += " CDEF:fast=kmh,100,GT,kmh,0,IF"
+ cmd += " CDEF:good=kmh,100,GT,0,kmh,IF"
+ cmd += " HRULE:100#0000FF:\"Maximum allowed\""
+ cmd += " AREA:good#00FF00:\"Good speed\""
+ cmd += " AREA:fast#FF0000:\"Too fast\""
+ self.assertRunOk(cmd, timeout=20)
+
+ # And again, we check the output file exists.
+ self.assertRunOk("test -s speed3.png")
--
2.47.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH 1/1] support/testing: add rrdtool runtime test
2024-10-12 22:15 [Buildroot] [PATCH 1/1] support/testing: add rrdtool runtime test Julien Olivain
@ 2024-10-31 19:52 ` Thomas Petazzoni via buildroot
2024-11-20 21:30 ` Peter Korsgaard
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-10-31 19:52 UTC (permalink / raw)
To: Julien Olivain; +Cc: buildroot
On Sun, 13 Oct 2024 00:15:29 +0200
Julien Olivain <ju.o@free.fr> wrote:
> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
> Patch tested in:
> https://gitlab.com/jolivain/buildroot/-/jobs/8070566041
> ---
> DEVELOPERS | 1 +
> support/testing/tests/package/test_rrdtool.py | 100 ++++++++++++++++++
> 2 files changed, 101 insertions(+)
> create mode 100644 support/testing/tests/package/test_rrdtool.py
Applied to master, thanks.
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH 1/1] support/testing: add rrdtool runtime test
2024-10-12 22:15 [Buildroot] [PATCH 1/1] support/testing: add rrdtool runtime test Julien Olivain
2024-10-31 19:52 ` Thomas Petazzoni via buildroot
@ 2024-11-20 21:30 ` Peter Korsgaard
1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2024-11-20 21:30 UTC (permalink / raw)
To: Julien Olivain; +Cc: buildroot
>>>>> "Julien" == Julien Olivain <ju.o@free.fr> writes:
> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
> Patch tested in:
> https://gitlab.com/jolivain/buildroot/-/jobs/8070566041
Committed to 2024.02.x and 2024.08.x, thanks.
--
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-20 21:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-12 22:15 [Buildroot] [PATCH 1/1] support/testing: add rrdtool runtime test Julien Olivain
2024-10-31 19:52 ` Thomas Petazzoni via buildroot
2024-11-20 21:30 ` Peter Korsgaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox