[libstxxl1] 02/04: Add autopkgtests.
Anton Gladky
gladk at moszumanska.debian.org
Fri Aug 29 20:07:34 UTC 2014
This is an automated email from the git hooks/post-receive script.
gladk pushed a commit to branch master
in repository libstxxl1.
commit e56aaad11c74460dfca3eb0468a1d12620dd12bb
Author: Anton Gladky <gladk at debian.org>
Date: Fri Aug 29 21:35:45 2014 +0200
Add autopkgtests.
---
debian/control | 1 +
debian/tests/buildDeque1 | 64 ++++++++++
debian/tests/buildDeque2 | 84 ++++++++++++
debian/tests/buildInit | 19 +++
debian/tests/buildMap1 | 82 ++++++++++++
debian/tests/buildPqueue1 | 74 +++++++++++
debian/tests/buildStream1 | 316 ++++++++++++++++++++++++++++++++++++++++++++++
debian/tests/control | 5 +-
debian/tests/unittests | 35 -----
9 files changed, 643 insertions(+), 37 deletions(-)
diff --git a/debian/control b/debian/control
index 8ebd77f..c5a20b8 100644
--- a/debian/control
+++ b/debian/control
@@ -9,6 +9,7 @@ Build-Depends: debhelper (>= 9), doxygen, doxygen-latex, texlive-fonts-extra,
texlive-latex-extra, graphviz, texlive-latex-recommended,
texlive-fonts-recommended, ghostscript, cmake
Standards-Version: 3.9.5
+XS-Testsuite: autopkgtest
Homepage: http://stxxl.sourceforge.net
Package: libstxxl1
diff --git a/debian/tests/buildDeque1 b/debian/tests/buildDeque1
new file mode 100755
index 0000000..33b644c
--- /dev/null
+++ b/debian/tests/buildDeque1
@@ -0,0 +1,64 @@
+#!/bin/sh
+# autopkgtest check
+# (C) 2014 Anton Gladky
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+
+cat <<EOF > demo.cpp
+/***************************************************************************
+ * examples/containers/deque1.cpp
+ *
+ * Part of the STXXL. See http://stxxl.sourceforge.net
+ *
+ * Copyright (C) 2013 Daniel Feist <daniel.feist at student.kit.edu>
+ *
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ **************************************************************************/
+
+//! [example]
+#include <stxxl/deque>
+#include <iostream>
+
+int main()
+{
+ typedef stxxl::deque<int> deque;
+ deque my_deque;
+
+ my_deque.push_front(2);
+ my_deque.push_front(11);
+ my_deque.push_back(5);
+ my_deque.push_back(8);
+ // deque now stores: |11|2|5|8|
+
+ std::cout << "return 'first' element: " << my_deque.front() << std::endl; // prints 11
+ std::cout << "return 'last' element: " << my_deque.back() << std::endl; // prints 8
+ std::cout << "random access: " << my_deque[2] << std::endl; // prints 5
+
+ // generate forward iterator
+ stxxl::deque_iterator<deque> deque_iterator = my_deque.begin();
+
+ // iterate over my_deque, access values and delete them afterwards
+ while (!my_deque.empty())
+ {
+ std::cout << *deque_iterator << " ";
+ ++deque_iterator;
+ my_deque.pop_front();
+ }
+
+ return 0;
+}
+//! [example]
+
+EOF
+
+g++ demo.cpp -o demo -lstxxl -lpthread -fopenmp
+echo "build: OK"
+[ -x demo ]
+./demo
+echo "run: OK"
diff --git a/debian/tests/buildDeque2 b/debian/tests/buildDeque2
new file mode 100755
index 0000000..8d12844
--- /dev/null
+++ b/debian/tests/buildDeque2
@@ -0,0 +1,84 @@
+#!/bin/sh
+# autopkgtest check
+# (C) 2014 Anton Gladky
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+
+cat <<EOF > demo.cpp
+/***************************************************************************
+ * examples/containers/deque2.cpp
+ *
+ * Part of the STXXL. See http://stxxl.sourceforge.net
+ *
+ * Copyright (C) 2013 Daniel Feist <daniel.feist at student.kit.edu>
+ *
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ **************************************************************************/
+
+#include <stxxl/deque>
+#include <iostream>
+
+int main()
+{
+ typedef stxxl::deque<unsigned int> deque;
+ deque my_deque;
+
+ unsigned int random, p, x;
+ unsigned int smaller_left = 0;
+ unsigned int smaller_right = 0;
+ stxxl::random_number32 rand32;
+ stxxl::uint64 number_of_elements = 8 * 1024 * 1024;
+
+ // fill deque with random integer values
+ for (stxxl::uint64 i = 0; i < number_of_elements; i++)
+ {
+ random = rand32(); // produce random integer from intervall [0,2^32)
+ my_deque.push_front(random);
+ }
+
+ stxxl::deque_iterator<deque> deque_iterator = my_deque.begin();
+
+ // Access random element x at position p(x) in the deque
+ p = rand32() % number_of_elements;
+ x = my_deque[p];
+
+ // Count number of smaller elements from the front to p(x) - 1
+ for (stxxl::uint64 j = 0; j < p; j++)
+ {
+ if (*deque_iterator < x)
+ {
+ smaller_left += 1;
+ }
+ ++deque_iterator;
+ }
+
+ ++deque_iterator;
+
+ // Count number of smaller elements from p(x) + 1 to the end
+ for (stxxl::uint64 k = p + 1; k < number_of_elements - 1; k++)
+ {
+ if (*deque_iterator < x)
+ {
+ smaller_right += 1;
+ }
+ ++deque_iterator;
+ }
+
+ STXXL_MSG("smaller left: " << smaller_left << ", smaller right: " << smaller_right);
+
+ return 0;
+}
+
+EOF
+
+g++ demo.cpp -o demo -lstxxl -lpthread -fopenmp
+echo "build: OK"
+[ -x demo ]
+./demo
+echo "run: OK"
diff --git a/debian/tests/buildInit b/debian/tests/buildInit
new file mode 100755
index 0000000..a71e3e7
--- /dev/null
+++ b/debian/tests/buildInit
@@ -0,0 +1,19 @@
+#!/bin/sh
+# autopkgtest check
+# (C) 2014 Anton Gladky
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+
+cat <<EOF > demo.cpp
+
+EOF
+
+g++ demo.cpp -o demo -lstxxl -lpthread -fopenmp
+echo "build: OK"
+[ -x demo ]
+./demo
+echo "run: OK"
diff --git a/debian/tests/buildMap1 b/debian/tests/buildMap1
new file mode 100755
index 0000000..b3b6aca
--- /dev/null
+++ b/debian/tests/buildMap1
@@ -0,0 +1,82 @@
+#!/bin/sh
+# autopkgtest check
+# (C) 2014 Anton Gladky
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+
+cat <<EOF > demo.cpp
+/***************************************************************************
+ * examples/containers/map1.cpp
+ *
+ * Part of the STXXL. See http://stxxl.sourceforge.net
+ *
+ * Copyright (C) 2013 Daniel Feist <daniel.feist at student.kit.edu>
+ *
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ **************************************************************************/
+
+//! [example]
+#include <stxxl/map>
+#include <iostream>
+
+#define DATA_NODE_BLOCK_SIZE (4096)
+#define DATA_LEAF_BLOCK_SIZE (4096)
+
+//! [comparator]
+struct CompareGreater
+{
+ bool operator () (const int& a, const int& b) const
+ { return a > b; }
+
+ static int max_value()
+ { return std::numeric_limits<int>::min(); }
+};
+//! [comparator]
+
+int main()
+{
+ // template parameter <KeyType, DataType, CompareType, RawNodeSize, RawLeafSize, PDAllocStrategy (optional)>
+ typedef stxxl::map<int, char, CompareGreater, DATA_NODE_BLOCK_SIZE, DATA_LEAF_BLOCK_SIZE> map_type;
+
+ // Constructor map(node_cache_size_in_bytes, leaf_cache_size_in_bytes)
+ map_type my_map((map_type::node_block_type::raw_size)*3, (map_type::leaf_block_type::raw_size)*3);
+
+ my_map.insert(std::pair<int, char>(1, 'a'));
+ my_map.insert(std::pair<int, char>(2, 'b'));
+ my_map.insert(std::pair<int, char>(3, 'c'));
+ my_map.insert(std::pair<int, char>(4, 'd'));
+
+ my_map.erase(3);
+
+ map_type::iterator iter;
+
+ std::cout << "my_map contains:\n";
+ for (iter = my_map.begin(); iter != my_map.end(); ++iter)
+ {
+ std::cout << iter->first << " => " << iter->second << std::endl;
+ }
+
+ map_type::iterator iter_low, iter_up;
+
+ iter_low = my_map.lower_bound(1); // iter_low points to (1,a) in this case
+ iter_up = my_map.upper_bound(3); // iter_up points to (2,b) in this case
+
+ std::cout << "lower bound " << iter_low->second << ", upper bound " << iter_up->second << std::endl;
+
+ return 0;
+}
+//! [example]
+
+EOF
+
+g++ demo.cpp -o demo -lstxxl -lpthread -fopenmp
+echo "build: OK"
+[ -x demo ]
+./demo
+echo "run: OK"
diff --git a/debian/tests/buildPqueue1 b/debian/tests/buildPqueue1
new file mode 100755
index 0000000..29b37a8
--- /dev/null
+++ b/debian/tests/buildPqueue1
@@ -0,0 +1,74 @@
+#!/bin/sh
+# autopkgtest check
+# (C) 2014 Anton Gladky
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+
+cat <<EOF > demo.cpp
+/***************************************************************************
+ * examples/containers/pqueue1.cpp
+ *
+ * Part of the STXXL. See http://stxxl.sourceforge.net
+ *
+ * Copyright (C) 2013 Daniel Feist <daniel.feist at student.kit.edu>
+ *
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ **************************************************************************/
+
+//! [example]
+#include <stxxl/priority_queue>
+#include <iostream>
+#include <limits>
+
+// comparison struct for priority queue where top() returns the smallest contained value:
+struct ComparatorGreater
+{
+ bool operator () (const int& a, const int& b) const
+ { return (a > b); }
+
+ int min_value() const
+ { return std::numeric_limits<int>::max(); }
+};
+
+int main()
+{
+ typedef stxxl::PRIORITY_QUEUE_GENERATOR<int, ComparatorGreater, 128*1024*1024, 1024*1024>::result pqueue_type;
+ typedef pqueue_type::block_type block_type;
+
+ // block_type::raw_size = 262144 bytes
+ // use 64 block read and write pools each to enable overlapping between I/O and computation
+ const unsigned int mem_for_pools = 32 * 1024 * 1024;
+ stxxl::read_write_pool<block_type> pool((mem_for_pools / 2) / block_type::raw_size, (mem_for_pools / 2) / block_type::raw_size);
+ pqueue_type my_pqueue(pool); // creates stxxl priority queue instance with read-write-pool
+
+ my_pqueue.push(5);
+ my_pqueue.push(4);
+ my_pqueue.push(19);
+ my_pqueue.push(1);
+ assert(my_pqueue.size() == 4);
+
+ assert(my_pqueue.top() == 1);
+ STXXL_MSG("Smallest inserted value in my: " << my_pqueue.top());
+
+ my_pqueue.pop(); // pop the 1 on top
+
+ assert(my_pqueue.top() == 4);
+ STXXL_MSG("Smallest value after 1 pop(): " << my_pqueue.top());
+
+ return 0;
+}
+//! [example]
+
+EOF
+
+g++ demo.cpp -o demo -lstxxl -lpthread -fopenmp
+echo "build: OK"
+[ -x demo ]
+./demo
+echo "run: OK"
diff --git a/debian/tests/buildStream1 b/debian/tests/buildStream1
new file mode 100755
index 0000000..5eb03df
--- /dev/null
+++ b/debian/tests/buildStream1
@@ -0,0 +1,316 @@
+#!/bin/sh
+# autopkgtest check
+# (C) 2014 Anton Gladky
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+
+cat <<EOF > demo.cpp
+/***************************************************************************
+ * examples/stream/stream1.cpp
+ *
+ * This file contains the example snippets from the stream tutorial.
+ *
+ * Part of the STXXL. See http://stxxl.sourceforge.net
+ *
+ * Copyright (C) 2012-2013 Timo Bingmann <tb at panthema.net>
+ *
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ **************************************************************************/
+
+#include <stxxl/stream>
+#include <stxxl/vector>
+#include <stxxl/sorter>
+
+#include <vector>
+#include <climits>
+
+struct counter_object
+{
+ // This stream produces a sequence of integers.
+ typedef int value_type;
+
+private:
+ // A class attribute to save the current value.
+ int m_current_value;
+
+public:
+ // A constructor to set the initial value to 1.
+ counter_object()
+ : m_current_value(1)
+ { }
+
+ // The retrieve operator returning the current value.
+ const value_type& operator * () const
+ {
+ return m_current_value;
+ }
+
+ // Increment operator advancing to the next integer.
+ counter_object& operator ++ ()
+ {
+ ++m_current_value;
+ return *this;
+ }
+
+ // Empty indicator, which in this case can check the current value.
+ bool empty() const
+ {
+ return (m_current_value > 1000);
+ }
+};
+
+template <typename InputStream>
+struct squaring_object
+{
+ // This stream produces a sequence of integers.
+ typedef int value_type;
+
+private:
+ // A reference to another stream of integers, which are our input.
+ InputStream& m_input_stream;
+
+ // A temporary value buffer to hold the current square in for retrieval.
+ value_type m_current_value;
+
+public:
+ // A constructor taking another stream of integers as input.
+ squaring_object(InputStream& input_stream)
+ : m_input_stream(input_stream)
+ {
+ if (!m_input_stream.empty())
+ {
+ m_current_value = *m_input_stream;
+ m_current_value = m_current_value * m_current_value;
+ }
+ }
+
+ // The retrieve operator returning the square of the input stream.
+ const value_type& operator * () const
+ {
+ return m_current_value;
+ }
+
+ // Increment operator: handled by incrementing the input stream.
+ squaring_object& operator ++ ()
+ {
+ ++m_input_stream;
+ if (!m_input_stream.empty())
+ {
+ m_current_value = *m_input_stream;
+ m_current_value = m_current_value * m_current_value;
+ }
+ return *this;
+ }
+
+ // Empty indicator: this stream is empty when the input stream is.
+ bool empty() const
+ {
+ return m_input_stream.empty();
+ }
+};
+
+// define comparator class: compare right-most decimal and then absolute value
+struct CompareMod10
+{
+ // comparison operator() returning true if (a < b)
+ inline bool operator () (int a, int b) const
+ {
+ if ((a % 10) == (b % 10))
+ return a < b;
+ else
+ return (a % 10) < (b % 10);
+ }
+
+ // smallest possible integer value
+ int min_value() const { return INT_MIN; }
+ // largest possible integer value
+ int max_value() const { return INT_MAX; }
+};
+
+int main()
+{
+ {
+ counter_object counter;
+
+ while (!counter.empty())
+ {
+ std::cout << *counter << " ";
+ ++counter;
+ }
+ std::cout << std::endl;
+ }
+
+ {
+ for (counter_object cnt; !cnt.empty(); ++cnt)
+ {
+ std::cout << *cnt << " ";
+ }
+ std::cout << std::endl;
+ }
+
+ {
+ counter_object counter;
+ squaring_object<counter_object> squares(counter);
+
+ while (!squares.empty())
+ {
+ std::cout << *squares << " ";
+ ++squares;
+ }
+ std::cout << std::endl;
+ }
+
+ {
+ std::vector<int> intvector;
+ // (fill intvector)
+
+ // define stream class iterating over an integer vector
+ typedef stxxl::stream::iterator2stream<std::vector<int>::const_iterator> intstream_type;
+
+ // instantiate the stream object, iterate from begin to end of intvector.
+ intstream_type intstream(intvector.begin(), intvector.end());
+
+ // plug in squaring object after vector iterator stream.
+ squaring_object<intstream_type> squares(intstream);
+ }
+
+ {
+ stxxl::vector<int> intvector;
+ // (fill intvector)
+
+ // define stream class iterating over an integer vector
+ typedef stxxl::stream::vector_iterator2stream<stxxl::vector<int>::const_iterator> intstream_type;
+
+ // instantiate the stream object, iterate from begin to end of intvector.
+ intstream_type intstream(intvector.begin(), intvector.end());
+
+ // plug in squaring object after vector iterator stream.
+ squaring_object<intstream_type> squares(intstream);
+ }
+
+ {
+ // construct the squared counter stream
+ counter_object counter;
+ squaring_object<counter_object> squares(counter);
+
+ // allocate vector of 100 integers
+ std::vector<int> intvector(100);
+
+ // materialize 100 integers from stream and put into vector
+ stxxl::stream::materialize(squares, intvector.begin(), intvector.end());
+ }
+
+ {
+ // construct the squared counter stream
+ counter_object counter;
+ squaring_object<counter_object> squares(counter);
+
+ // allocate STXXL vector of 100 integers
+ stxxl::vector<int> intvector(100);
+
+ // materialize 100 integers from stream and put into STXXL vector
+ stxxl::stream::materialize(squares, intvector.begin(), intvector.end());
+ }
+
+ {
+ static const int ram_use = 10 * 1024 * 1024; // amount of memory to use in runs creation
+
+ counter_object counter; // the counter stream from first examples
+
+ // define a runs sorter for the counter stream which order by CompareMod10 object.
+ typedef stxxl::stream::runs_creator<counter_object, CompareMod10> rc_counter_type;
+
+ // instance of CompareMod10 comparator class
+ CompareMod10 comparemod10;
+
+ // instance of runs_creator which reads the counter stream.
+ rc_counter_type rc_counter(counter, comparemod10, ram_use);
+
+ // define a runs merger for the sorted runs from rc_counter.
+ typedef stxxl::stream::runs_merger<rc_counter_type::sorted_runs_type, CompareMod10> rm_counter_type;
+
+ // instance of runs_merger which merges sorted runs from rc_counter.
+ rm_counter_type rm_counter(rc_counter.result(), comparemod10, ram_use);
+
+ // read sorted stream: runs_merger also conforms to the stream interface.
+ while (!rm_counter.empty())
+ {
+ std::cout << *rm_counter << " ";
+ ++rm_counter;
+ }
+ std::cout << std::endl;
+ }
+
+ {
+ static const int ram_use = 10 * 1024 * 1024; // amount of memory to use in runs creation
+
+ // define a runs sorter which accepts imperative push()s and orders by CompareMod10 object.
+ typedef stxxl::stream::runs_creator<stxxl::stream::use_push<int>, CompareMod10> rc_counter_type;
+
+ // instance of CompareMod10 comparator class.
+ CompareMod10 comparemod10;
+
+ // instance of runs_creator which waits for input.
+ rc_counter_type rc_counter(comparemod10, ram_use);
+
+ // write sequence of integers into runs
+ for (int i = 1; i <= 1000; ++i)
+ rc_counter.push(i);
+
+ // define a runs merger for the sorted runs from rc_counter.
+ typedef stxxl::stream::runs_merger<rc_counter_type::sorted_runs_type, CompareMod10> rm_counter_type;
+
+ // instance of runs_merger which merges sorted runs from rc_counter.
+ rm_counter_type rm_counter(rc_counter.result(), comparemod10, ram_use);
+
+ // read sorted stream: runs_merger also conforms to the stream interface.
+ while (!rm_counter.empty())
+ {
+ std::cout << *rm_counter << " ";
+ ++rm_counter;
+ }
+ std::cout << std::endl;
+ }
+
+ {
+ static const int ram_use = 10 * 1024 * 1024; // amount of memory to use in runs creation
+
+ // define a runs sorter which accepts imperative push()s and orders by CompareMod10 object.
+ typedef stxxl::sorter<int, CompareMod10> sr_counter_type;
+
+ // instance of CompareMod10 comparator class.
+ CompareMod10 comparemod10;
+
+ // instance of sorter which waits for input.
+ sr_counter_type sr_counter(comparemod10, ram_use);
+
+ // write sequence of integers into sorter, which creates sorted runs
+ for (int i = 1; i <= 1000; ++i)
+ sr_counter.push(i);
+
+ // signal sorter that the input stream is finished and switch to output mode.
+ sr_counter.sort();
+
+ // read sorted stream: sorter also conforms to the stream interface.
+ while (!sr_counter.empty())
+ {
+ std::cout << *sr_counter << " ";
+ ++sr_counter;
+ }
+ std::cout << std::endl;
+ }
+}
+
+EOF
+
+g++ demo.cpp -o demo -lstxxl -lpthread -fopenmp
+echo "build: OK"
+[ -x demo ]
+./demo
+echo "run: OK"
diff --git a/debian/tests/control b/debian/tests/control
index 718158e..eef5cc6 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,2 +1,3 @@
-Tests: unittests
-Depends: libstxxl-dev, g++
+Tests: buildDeque1 buildDeque2 buildMap1 buildPqueue1 buildStream1
+Depends: libstxxl-dev, build-essential
+Restrictions: allow-stderr
diff --git a/debian/tests/unittests b/debian/tests/unittests
deleted file mode 100755
index 86c4b59..0000000
--- a/debian/tests/unittests
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-
-
-#Quickly compile and run test program
-#--
-echo "#include <stxxl.h>
-int main() {
- stxxl::vector<int> v;
- v.resize(10,1);
- int sum=0;
- for(size_t ui=0;ui<10; ui++)
- sum+=v[ui];
- if (sum == 10*10/2)
- return 0;
- else
- return 1;
-}" > test_program.cpp
-
-#Compile.
-g++ test_program.cpp -o test_program -lstxxl
-
-if [ $? -ne 0 ] ; then
- exit 1;
-fi
-
-#run program
-./test_program
-if [ $? -ne 0 ] ; then
- exit 2;
-fi
-
-
-#--
-
-
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/libstxxl1.git
More information about the debian-science-commits
mailing list