# # # add_file "unit-tests/mkstemp.cc" # content [a4272b124940a7e051422e38b85d6a71e0f57222] # # patch "Makefile.am" # from [20f78b04f42fd211452eb3ab827e170685da7145] # to [ed7fa88d28e048f5415f34a938393975d00c9152] # # patch "mkstemp.cc" # from [d6eb71b1fd749510afaf0a27ecf771ed5de8e10e] # to [22bb6303b6a7f3f2394490a6dab856f74b9de069] # # patch "mt_version.cc" # from [9ef68879610b15149d17831bd47dd8b470cc231c] # to [8389644e15bf83ea03708a60f4b6158f73848fcf] # ============================================================ --- unit-tests/mkstemp.cc a4272b124940a7e051422e38b85d6a71e0f57222 +++ unit-tests/mkstemp.cc a4272b124940a7e051422e38b85d6a71e0f57222 @@ -0,0 +1,71 @@ +// Copyright (C) 2009 Zack Weinberg +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. + +#include "base.hh" +#include "unit_tests.hh" +#include "mkstemp.hh" +#include "sanity.hh" + +#include +#include + +using std::string; +using std::strerror; + +UNIT_TEST(basic) +{ + // This test verifies that we can create 100x3 temporary files in the + // same directory (using 3 different templates) and that the correct + // part of the template pathname is modified in each case. + + char const * const cases[4] = { + "a-XXXXXX", "XXXXXX-b", "c-XXXXXX.dat", 0 + }; + + for (int i = 0; cases[i]; i++) + for (int j = 0; j < 100; j++) + { + string r(cases[i]); + string s(cases[i]); + if (monotone_mkstemp(s)) + { + UNIT_TEST_CHECK_MSG(r.length() == s.length(), + FL("same length: from %s got %s") + % r % s); + bool no_scribble = true; + for (string::size_type n = 0; n < r.length(); n++) + { + bool ok = r[n] == s[n]; + if (r[n] == 'X') + ok = !ok; + if (!ok) + no_scribble = false; + } + UNIT_TEST_CHECK_MSG(no_scribble, + FL("modify correct segment: from %s got %s") + % r % s); + } + else + { + UNIT_TEST_CHECK_MSG(false, + FL("mkstemp failed with template %s " + "(iteration %d, os error %s)") + % r % (j+1) % strerror(errno)); + break; + } + } +} + +// Local Variables: +// mode: C++ +// fill-column: 76 +// c-file-style: "gnu" +// indent-tabs-mode: nil +// End: +// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s: ============================================================ --- Makefile.am 20f78b04f42fd211452eb3ab827e170685da7145 +++ Makefile.am ed7fa88d28e048f5415f34a938393975d00c9152 @@ -129,10 +129,10 @@ UNIT_TESTEES = \ UNIT_TESTEES = \ basic_io.cc charset.cc commands.cc cset.cc globish.cc graph.cc \ - merge_3way.cc merge_roster.cc netcmd.cc netxx_pipe.cc \ - option.cc outdated_indicator.cc refiner.cc restrictions.cc \ - revision.cc simplestring_xform.cc transforms.cc uri.cc \ - vocab.cc xdelta.cc + merge_3way.cc merge_roster.cc mkstemp.cc netcmd.cc \ + netxx_pipe.cc option.cc outdated_indicator.cc refiner.cc \ + restrictions.cc revision.cc simplestring_xform.cc \ + transforms.cc uri.cc vocab.cc xdelta.cc # these files contain the actual unit tests # yes, we have to list them all explicitly, with directory prefix, or @@ -142,12 +142,12 @@ UNIT_TESTERS = \ unit-tests/commands.cc unit-tests/cset.cc \ unit-tests/globish.cc unit-tests/graph.cc \ unit-tests/merge_3way.cc unit-tests/merge_roster.cc \ - unit-tests/netcmd.cc unit-tests/netxx_pipe.cc \ - unit-tests/option.cc unit-tests/outdated_indicator.cc \ - unit-tests/refiner.cc unit-tests/restrictions.cc \ - unit-tests/revision.cc unit-tests/simplestring_xform.cc \ - unit-tests/transforms.cc unit-tests/uri.cc unit-tests/vocab.cc \ - unit-tests/xdelta.cc \ + unit-tests/mkstemp.cc unit-tests/netcmd.cc \ + unit-tests/netxx_pipe.cc unit-tests/option.cc \ + unit-tests/outdated_indicator.cc unit-tests/refiner.cc \ + unit-tests/restrictions.cc unit-tests/revision.cc \ + unit-tests/simplestring_xform.cc unit-tests/transforms.cc \ + unit-tests/uri.cc unit-tests/vocab.cc unit-tests/xdelta.cc \ \ unit-tests/numeric_vocab.cc unit-tests/sha1.cc \ unit-tests/string_queue.cc unit_tester.cc @@ -184,7 +184,7 @@ tester_SOURCES = tester.cc transforms.cc tester_SOURCES = tester.cc transforms.cc gzip.cc \ $(SANITY_CORE_SOURCES) $(LUAEXT_SOURCES) pcrewrap.cc -nodist_tester_SOURCES = testlib.c +nodist_tester_SOURCES = testlib.cc txt2c_SOURCES = txt2c.cc @@ -235,17 +235,17 @@ AM_CXXFLAGS = $(PCH_FLAGS) $(lua_CFLAGS) $(sqlite_CFLAGS) $(idn_CFLAGS) AM_CXXFLAGS = $(PCH_FLAGS) -LDADD = $(BOOSTLIBS) $(LIBICONV) $(LIBINTL) $(pcre_LIBS) \ - $(botan_LIBS) $(lua_LIBS) $(sqlite_LIBS) $(idn_LIBS) +LDADD = libplatform.a lib3rdparty.a $(BOOSTLIBS) $(LIBINTL) \ + $(LIBICONV) $(pcre_LIBS) $(botan_LIBS) $(lua_LIBS) \ + $(sqlite_LIBS) $(idn_LIBS) if WIN32_PLATFORM libplatform_a_SOURCES += $(WIN32_PLATFORM_SOURCES) mtn_SOURCES += win32/main.cc - mtn_LDADD = -lshfolder -lws2_32 -lintl -liconv -liphlpapi - unit_tester_LDADD = -lshfolder -lws2_32 -lintl -liconv -liphlpapi - AM_CPPFLAGS += -DWIN32 tester_SOURCES += win32/tester-plaf.cc check_net_SOURCES = win32/tester-check-net.cc + AM_CPPFLAGS += -DWIN32 + LDADD += -lshfolder -lws2_32 -lintl -liconv -liphlpapi else libplatform_a_SOURCES += $(UNIX_PLATFORM_SOURCES) mtn_SOURCES += unix/main.cc ============================================================ --- mkstemp.cc d6eb71b1fd749510afaf0a27ecf771ed5de8e10e +++ mkstemp.cc 22bb6303b6a7f3f2394490a6dab856f74b9de069 @@ -44,6 +44,7 @@ // and it can be extremely poor quality (RANDU, anyone?) #include "base.hh" +#include "mkstemp.hh" #include "numeric_vocab.hh" #include @@ -161,55 +162,6 @@ monotone_mkstemp(string & tmpl) return false; } -#ifdef BUILD_UNIT_TESTS -#include "sanity.hh" -#include "unit_tests.hh" - -UNIT_TEST(mkstemp, basic) -{ - // This test verifies that we can create 100x3 temporary files in the - // same directory (using 3 different templates) and that the correct - // part of the template pathname is modified in each case. - - char const * const cases[4] = { - "a-XXXXXX", "XXXXXX-b", "c-XXXXXX.dat", 0 - }; - - for (int i = 0; cases[i]; i++) - for (int j = 0; j < 100; j++) - { - string r(cases[i]); - string s(cases[i]); - if (monotone_mkstemp(s)) - { - UNIT_TEST_CHECK_MSG(r.length() == s.length(), - FL("same length: from %s got %s") - % r % s); - bool no_scribble = true; - for (string::size_type n = 0; n < r.length(); n++) - { - bool ok = r[n] == s[n]; - if (r[n] == 'X') - ok = !ok; - if (!ok) - no_scribble = false; - } - UNIT_TEST_CHECK_MSG(no_scribble, - FL("modify correct segment: from %s got %s") - % r % s); - } - else - { - UNIT_TEST_CHECK_MSG(false, - FL("mkstemp failed with template %s " - "(iteration %d, os error %s)") - % r % (j+1) % strerror(errno)); - break; - } - } -} -#endif - // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- mt_version.cc 9ef68879610b15149d17831bd47dd8b470cc231c +++ mt_version.cc 8389644e15bf83ea03708a60f4b6158f73848fcf @@ -68,7 +68,7 @@ get_full_version(string & out) "Botan version : %d.%d.%d (compiled against %d.%d.%d)\n" "Changes since base revision:\n" "%s") - % s + % base_version % flavour % BOOST_COMPILER % BOOST_STDLIB % BOOST_LIB_VERSION