[med-svn] [Git][med-team/concurrentqueue][master] 2 commits: Build seems to happen concurrently hence added a -p flag - the build works and...
Nilesh Patra
gitlab at salsa.debian.org
Wed Nov 4 13:05:14 GMT 2020
Nilesh Patra pushed to branch master at Debian Med / concurrentqueue
Commits:
f6fa01d8 by Nilesh Patra at 2020-11-04T18:34:06+05:30
Build seems to happen concurrently hence added a -p flag - the build works and the package is functional
- - - - -
7bd854e7 by Nilesh Patra at 2020-11-04T18:34:15+05:30
Add autopkgtest
- - - - -
7 changed files:
- + debian/examples
- debian/patches/dontBuildBenchmark.patch
- + debian/tests/control
- + debian/tests/run-unit-test
- + debian/tests/test1.cpp
- + debian/tests/test2.cpp
- + debian/tests/test3.cpp
Changes:
=====================================
debian/examples
=====================================
@@ -0,0 +1,2 @@
+debian/tests/*.cpp
+debian/tests/run-unit-test
=====================================
debian/patches/dontBuildBenchmark.patch
=====================================
@@ -1,10 +1,12 @@
-Author: Steffen Möller
-Last-Update: 2020-06-29 23:49:01 +0200
+Author: Steffen Möller <moeller at debian.org>, Nilesh Patra <npatra974 at gmail.com>
+Last-Update: 2020-11-04 18:31:21 +0530
+Forwarded: not-needed
Description: Do not build benchmarks
+ The build seems to happen concurrently - hence appeneded a -p with mkdir.
--- a/build/makefile
+++ b/build/makefile
-@@ -27,7 +27,7 @@ default: tests benchmarks
+@@ -27,22 +27,22 @@
tests: bin/unittests$(EXT) bin/fuzztests$(EXT)
@@ -12,4 +14,23 @@ Description: Do not build benchmarks
+benchmarks:
bin/unittests$(EXT): ../concurrentqueue.h ../blockingconcurrentqueue.h ../lightweightsemaphore.h ../tests/unittests/unittests.cpp ../tests/unittests/mallocmacro.cpp ../tests/common/simplethread.h ../tests/common/simplethread.cpp ../tests/common/systemtime.h ../tests/common/systemtime.cpp ../tests/corealgos.h ../tests/unittests/minitest.h makefile
- test -d bin || mkdir bin
+- test -d bin || mkdir bin
++ test -d bin || mkdir -p bin
+ g++ -std=c++11 -Wall -pedantic-errors -Wpedantic -Wconversion $(OPTS) -fno-elide-constructors ../tests/common/simplethread.cpp ../tests/common/systemtime.cpp ../tests/unittests/unittests.cpp -o bin/unittests$(EXT) $(LD_OPTS)
+
+ bin/fuzztests$(EXT): ../concurrentqueue.h ../tests/fuzztests/fuzztests.cpp ../tests/common/simplethread.h ../tests/common/simplethread.cpp ../tests/common/systemtime.h ../tests/common/systemtime.cpp ../tests/corealgos.h makefile
+- test -d bin || mkdir bin
++ test -d bin || mkdir -p bin
+ g++ -std=c++11 -Wall -pedantic-errors -Wpedantic $(BENCH_OPTS) ../tests/common/simplethread.cpp ../tests/common/systemtime.cpp ../tests/fuzztests/fuzztests.cpp -o bin/fuzztests$(EXT) $(LD_OPTS)
+
+ bin/benchmarks$(EXT): bin/libtbb.a ../concurrentqueue.h ../benchmarks/benchmarks.cpp ../benchmarks/cpuid.h ../benchmarks/cpuid.cpp ../benchmarks/lockbasedqueue.h ../benchmarks/simplelockfree.h ../tests/common/simplethread.h ../tests/common/simplethread.cpp ../tests/common/systemtime.h ../tests/common/systemtime.cpp makefile
+- test -d bin || mkdir bin
++ test -d bin || mkdir -p bin
+ g++ -std=c++11 -Wall -pedantic-errors -Wpedantic $(BENCH_OPTS) -I../benchmarks ../benchmarks/cpuid.cpp ../tests/common/simplethread.cpp ../tests/common/systemtime.cpp ../benchmarks/benchmarks.cpp -o bin/benchmarks$(EXT) -Lbin -ltbb $(LD_OPTS)
+
+ bin/libtbb.a: makefile
+- test -d bin || mkdir bin
++ test -d bin || mkdir -p bin
+ g++ -std=c++11 -O2 -DNDEBUG -D__TBB_BUILD=1 $(TBB_PLATFORM_OPTS) -I../benchmarks -c ../benchmarks/tbb/cache_aligned_allocator.cpp ../benchmarks/tbb/concurrent_monitor.cpp ../benchmarks/tbb/concurrent_queue.cpp ../benchmarks/tbb/dynamic_link.cpp ../benchmarks/tbb/tbb_misc.cpp
+ ar -rc bin/libtbb.a cache_aligned_allocator.o concurrent_monitor.o concurrent_queue.o dynamic_link.o tbb_misc.o
+ rm -f cache_aligned_allocator.o concurrent_monitor.o concurrent_queue.o dynamic_link.o tbb_misc.o
=====================================
debian/tests/control
=====================================
@@ -0,0 +1,3 @@
+Tests: run-unit-test
+Depends: @, build-essential
+Restrictions: allow-stderr
=====================================
debian/tests/run-unit-test
=====================================
@@ -0,0 +1,26 @@
+#!/bin/bash
+set -e
+
+pkg=libconcurrentqueue-dev
+
+if [ "${AUTOPKGTEST_TMP}" = "" ] ; then
+ AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
+ trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
+fi
+
+cp -a /usr/share/doc/${pkg}/examples/* "${AUTOPKGTEST_TMP}"
+
+cd "${AUTOPKGTEST_TMP}"
+
+function test_output()
+{
+ echo "Test $1"
+ g++ $2 -lpthread -o test
+ ./test
+ echo "PASS"
+}
+
+test_output 1 test1.cpp
+test_output 2 test2.cpp
+test_output 3 test3.cpp
+
=====================================
debian/tests/test1.cpp
=====================================
@@ -0,0 +1,16 @@
+#include <iostream>
+#include <cassert>
+#include "concurrentqueue/concurrentqueue.h"
+
+int main()
+{
+ moodycamel::ConcurrentQueue<int> q;
+ for (int i = 0; i != 123; ++i)
+ q.enqueue(i);
+
+ int item;
+ for (int i = 0; i != 123; ++i) {
+ q.try_dequeue(item);
+ assert(item == i);
+ }
+}
=====================================
debian/tests/test2.cpp
=====================================
@@ -0,0 +1,46 @@
+#include <iostream>
+#include <cassert>
+#include "concurrentqueue/concurrentqueue.h"
+
+int main()
+{
+ moodycamel::ConcurrentQueue<int> q;
+ int dequeued[100] = { 0 };
+ std::thread threads[20];
+
+ for (int i = 0; i != 10; ++i) {
+ threads[i] = std::thread([&](int i) {
+ for (int j = 0; j != 10; ++j) {
+ q.enqueue(i * 10 + j);
+ }
+ }, i);
+ }
+
+ // Consumers
+ for (int i = 10; i != 20; ++i) {
+ threads[i] = std::thread([&]() {
+ int item;
+ for (int j = 0; j != 20; ++j) {
+ if (q.try_dequeue(item)) {
+ ++dequeued[item];
+ }
+ }
+ });
+ }
+
+ // Wait for all threads
+ for (int i = 0; i != 20; ++i) {
+ threads[i].join();
+ }
+
+ // Collect any leftovers (could be some if e.g. consumers finish before producers)
+ int item;
+ while (q.try_dequeue(item)) {
+ ++dequeued[item];
+ }
+
+ // Make sure everything went in and came back out!
+ for (int i = 0; i != 100; ++i) {
+ assert(dequeued[i] == 1);
+ }
+}
=====================================
debian/tests/test3.cpp
=====================================
@@ -0,0 +1,50 @@
+#include <iostream>
+#include <cassert>
+#include "concurrentqueue/concurrentqueue.h"
+
+int main()
+{
+ moodycamel::ConcurrentQueue<int> q;
+ int dequeued[100] = { 0 };
+ std::thread threads[20];
+
+ // Producers
+ for (int i = 0; i != 10; ++i) {
+ threads[i] = std::thread([&](int i) {
+ int items[10];
+ for (int j = 0; j != 10; ++j) {
+ items[j] = i * 10 + j;
+ }
+ q.enqueue_bulk(items, 10);
+ }, i);
+ }
+
+ // Consumers
+ for (int i = 10; i != 20; ++i) {
+ threads[i] = std::thread([&]() {
+ int items[20];
+ for (std::size_t count = q.try_dequeue_bulk(items, 20); count != 0; --count) {
+ ++dequeued[items[count - 1]];
+ }
+ });
+ }
+
+ // Wait for all threads
+ for (int i = 0; i != 20; ++i) {
+ threads[i].join();
+ }
+
+ // Collect any leftovers (could be some if e.g. consumers finish before producers)
+ int items[10];
+ std::size_t count;
+ while ((count = q.try_dequeue_bulk(items, 10)) != 0) {
+ for (std::size_t i = 0; i != count; ++i) {
+ ++dequeued[items[i]];
+ }
+ }
+
+ // Make sure everything went in and came back out!
+ for (int i = 0; i != 100; ++i) {
+ assert(dequeued[i] == 1);
+ }
+}
View it on GitLab: https://salsa.debian.org/med-team/concurrentqueue/-/compare/5342e63de4afeef02dd3799886b1d6be55d6bb4b...7bd854e71bab22c0538ec6accbfd7b1c4e7afac4
--
View it on GitLab: https://salsa.debian.org/med-team/concurrentqueue/-/compare/5342e63de4afeef02dd3799886b1d6be55d6bb4b...7bd854e71bab22c0538ec6accbfd7b1c4e7afac4
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20201104/4a079aa8/attachment-0001.html>
More information about the debian-med-commit
mailing list