[MERGED] osmo-trx[master]: tests: InterThread: adapt to have reproducible output and en...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Jan 12 13:07:22 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: tests: InterThread: adapt to have reproducible output and enable autotest
......................................................................


tests: InterThread: adapt to have reproducible output and enable autotest

Change-Id: I05d4067890b526bd72d2eb31cf76de43ee11e80f
---
M tests/CommonLibs/InterthreadTest.cpp
M tests/CommonLibs/InterthreadTest.ok
M tests/testsuite.at
3 files changed, 33 insertions(+), 91 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/tests/CommonLibs/InterthreadTest.cpp b/tests/CommonLibs/InterthreadTest.cpp
index 03445d9..c131c2a 100644
--- a/tests/CommonLibs/InterthreadTest.cpp
+++ b/tests/CommonLibs/InterthreadTest.cpp
@@ -35,14 +35,20 @@
 InterthreadQueue<int> gQ;
 InterthreadMap<int,int> gMap;
 
+int q_last_read_val = -1;
+int q_last_write_val;
+int m_last_read_val;
+int m_last_write_val;
+
 void* qWriter(void*)
 {
 	int *p;
 	for (int i=0; i<20; i++) {
 		p = new int;
 		*p = i;
-		COUT("queue write " << *p);
+		CERR("queue write " << *p);
 		gQ.write(p);
+		q_last_write_val = i;
 		if (random()%2) sleep(1);
 	}
 	p = new int;
@@ -56,8 +62,14 @@
 	bool done = false;
 	while (!done) {
 		int *p = gQ.read();
-		COUT("queue read " << *p);
-		if (*p<0) done=true;
+		CERR("queue read " << *p);
+		if (*p<0) {
+			assert(q_last_read_val == 19 && *p == -1);
+			done = true;
+		} else {
+			assert(q_last_read_val == *p - 1);
+			q_last_read_val = *p;
+		}
 		delete p;
 	}
 	return NULL;
@@ -70,8 +82,9 @@
 	for (int i=0; i<20; i++) {
 		p = new int;
 		*p = i;
-		COUT("map write " << *p);
+		CERR("map write " << *p);
 		gMap.write(i,p);
+		m_last_write_val = i;
 		if (random()%2) sleep(1);
 	}
 	return NULL;
@@ -81,7 +94,9 @@
 {
 	for (int i=0; i<20; i++) {
 		int *p = gMap.read(i);
-		COUT("map read " << *p);
+		CERR("map read " << *p);
+		assert(*p == i);
+		m_last_read_val = *p;
 		// InterthreadMap will delete the pointers
 		// delete p;
 	}
@@ -109,6 +124,13 @@
 	qWriterThread.join();
 	mapReaderThread.join();
 	mapWriterThread.join();
+
+	assert(q_last_write_val == 19);
+	assert(q_last_read_val == 19);
+	assert(m_last_write_val == 19);
+	assert(m_last_read_val == 19);
+
+	printf("Done\n");
 }
 
 
diff --git a/tests/CommonLibs/InterthreadTest.ok b/tests/CommonLibs/InterthreadTest.ok
index db382bb..a965a70 100644
--- a/tests/CommonLibs/InterthreadTest.ok
+++ b/tests/CommonLibs/InterthreadTest.ok
@@ -1,81 +1 @@
-1515515500.150033 140715424245504: queue write 0
-1515515500.150105 140715423979264: map write 0
-1515515500.150132 140715423979264: map write 1
-1515515500.150143 140715424777984: queue read 0
-1515515500.150175 140715424511744: map read 0
-1515515500.150194 140715424511744: map read 1
-1515515501.150203 140715424245504: queue write 1
-1515515501.150288 140715423979264: map write 2
-1515515501.150334 140715424777984: queue read 1
-1515515501.150366 140715424511744: map read 2
-1515515502.150405 140715424245504: queue write 2
-1515515502.150488 140715423979264: map write 3
-1515515502.150533 140715424777984: queue read 2
-1515515502.150612 140715423979264: map write 4
-1515515502.150642 140715423979264: map write 5
-1515515502.150662 140715424511744: map read 3
-1515515502.150680 140715424511744: map read 4
-1515515502.150686 140715424511744: map read 5
-1515515503.150607 140715424245504: queue write 3
-1515515503.150709 140715424777984: queue read 3
-1515515503.150741 140715423979264: map write 6
-1515515503.150760 140715423979264: map write 7
-1515515503.150776 140715424511744: map read 6
-1515515503.150788 140715424511744: map read 7
-1515515504.150770 140715424245504: queue write 4
-1515515504.150839 140715424245504: queue write 5
-1515515504.150857 140715423979264: map write 8
-1515515504.150876 140715424777984: queue read 4
-1515515504.150904 140715424777984: queue read 5
-1515515504.150919 140715424511744: map read 8
-1515515505.150990 140715424245504: queue write 6
-1515515505.151066 140715423979264: map write 9
-1515515505.151095 140715424245504: queue write 7
-1515515505.151127 140715424245504: queue write 8
-1515515505.151143 140715424245504: queue write 9
-1515515505.151163 140715424245504: queue write 10
-1515515505.151179 140715424777984: queue read 6
-1515515505.151210 140715424777984: queue read 7
-1515515505.151217 140715424777984: queue read 8
-1515515505.151221 140715424777984: queue read 9
-1515515505.151226 140715424777984: queue read 10
-1515515505.151249 140715423979264: map write 10
-1515515505.151277 140715424511744: map read 9
-1515515505.151291 140715424511744: map read 10
-1515515505.151298 140715423979264: map write 11
-1515515505.151317 140715424511744: map read 11
-1515515506.151303 140715424245504: queue write 11
-1515515506.151386 140715423979264: map write 12
-1515515506.151414 140715424777984: queue read 11
-1515515506.151457 140715424511744: map read 12
-1515515506.151528 140715423979264: map write 13
-1515515506.151567 140715423979264: map write 14
-1515515506.151577 140715423979264: map write 15
-1515515506.151601 140715424511744: map read 13
-1515515506.151621 140715424511744: map read 14
-1515515506.151628 140715424511744: map read 15
-1515515507.151498 140715424245504: queue write 12
-1515515507.151606 140715424777984: queue read 12
-1515515507.151654 140715423979264: map write 16
-1515515507.151711 140715424511744: map read 16
-1515515508.151707 140715424245504: queue write 13
-1515515508.151778 140715423979264: map write 17
-1515515508.151816 140715423979264: map write 18
-1515515508.151830 140715424511744: map read 17
-1515515508.151870 140715424511744: map read 18
-1515515508.151904 140715423979264: map write 19
-1515515508.151963 140715424777984: queue read 13
-1515515508.151997 140715424511744: map read 19
-1515515509.151920 140715424245504: queue write 14
-1515515509.152023 140715424777984: queue read 14
-1515515510.152109 140715424245504: queue write 15
-1515515510.152218 140715424777984: queue read 15
-1515515511.152258 140715424245504: queue write 16
-1515515511.152380 140715424777984: queue read 16
-1515515512.152409 140715424245504: queue write 17
-1515515512.152449 140715424245504: queue write 18
-1515515512.152458 140715424777984: queue read 17
-1515515512.152477 140715424777984: queue read 18
-1515515513.152574 140715424245504: queue write 19
-1515515513.152674 140715424777984: queue read 19
-1515515513.152708 140715424777984: queue read -1
+Done
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 2c1e0b5..5d519d2 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -7,11 +7,11 @@
 AT_CHECK([$abs_top_builddir/tests/CommonLibs/BitVectorTest], [], [expout], [])
 AT_CLEANUP
 
-#AT_SETUP([InterthreadTest])
-#AT_KEYWORDS([InterthreadTest])
-#cat $abs_srcdir/CommonLibs/InterthreadTest.ok > expout
-#AT_CHECK([$abs_top_builddir/tests/CommonLibs/InterthreadTest], [], [expout], [])
-#AT_CLEANUP
+AT_SETUP([InterthreadTest])
+AT_KEYWORDS([InterthreadTest])
+cat $abs_srcdir/CommonLibs/InterthreadTest.ok > expout
+AT_CHECK([$abs_top_builddir/tests/CommonLibs/InterthreadTest], [], [expout], [ignore])
+AT_CLEANUP
 
 #AT_SETUP([LogTest])
 #AT_KEYWORDS([LogTest])

-- 
To view, visit https://gerrit.osmocom.org/5707
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I05d4067890b526bd72d2eb31cf76de43ee11e80f
Gerrit-PatchSet: 2
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>



More information about the gerrit-log mailing list