aboutsummaryrefslogtreecommitdiff
path: root/mysql/truncation
diff options
context:
space:
mode:
Diffstat (limited to 'mysql/truncation')
-rw-r--r--mysql/truncation/buildfile35
-rw-r--r--mysql/truncation/driver.cxx20
-rw-r--r--mysql/truncation/makefile107
-rw-r--r--mysql/truncation/test.std0
-rw-r--r--mysql/truncation/testscript11
5 files changed, 57 insertions, 116 deletions
diff --git a/mysql/truncation/buildfile b/mysql/truncation/buildfile
new file mode 100644
index 0000000..fbd936b
--- /dev/null
+++ b/mysql/truncation/buildfile
@@ -0,0 +1,35 @@
+# file : mysql/truncation/buildfile
+# license : GNU GPL v2; see accompanying LICENSE file
+
+assert ($mysql && !$multi || $build.meta_operation == 'dist') \
+"mysql should be configured via config.odb_tests.database variable as a single database"
+
+import libodb = libodb%lib{odb}
+
+import libs = libodb-mysql%lib{odb-mysql}
+import libs += lib{common}
+
+exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript
+
+# Introduce the metadata library target to make sure the libodb library is
+# resolved for the odb_compile ad hoc rule (see build/root.build for details).
+#
+libue{test-meta}: $libodb
+
+<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta}
+
+exe{driver}: libue{test-meta} $libs
+
+# Specify the ODB custom options to be used by the odb_compile ad hoc rule
+# (see build/root.build for details).
+#
+odb_options = --table-prefix mysql_truncation_ \
+ --generate-schema \
+ --default-database common \
+ --generate-query
+
+cxx.poptions =+ "-I$out_base" "-I$src_base"
+
+# Testscript's run-time prerequisites.
+#
+exe{driver}: ../../alias{mysql-client}: include = adhoc
diff --git a/mysql/truncation/driver.cxx b/mysql/truncation/driver.cxx
index 9f044e6..21084f5 100644
--- a/mysql/truncation/driver.cxx
+++ b/mysql/truncation/driver.cxx
@@ -4,19 +4,21 @@
// Test insufficient buffer/truncation handling.
//
-#include <memory> // std::auto_ptr
-#include <cassert>
+#include <memory> // std::unique_ptr
#include <iostream>
#include <odb/mysql/database.hxx>
#include <odb/mysql/connection.hxx>
#include <odb/mysql/transaction.hxx>
-#include <common/common.hxx>
+#include <libcommon/common.hxx>
#include "test.hxx"
#include "test-odb.hxx"
+#undef NDEBUG
+#include <cassert>
+
using namespace std;
namespace mysql = odb::mysql;
using namespace mysql;
@@ -34,7 +36,7 @@ main (int argc, char* argv[])
// Test basic operations.
//
{
- auto_ptr<database> db (create_specific_database<database> (argc, argv));
+ unique_ptr<database> db (create_specific_database<database> (argc, argv));
// Run persist/load so that the initial bindings are established
// (version == 0).
@@ -72,7 +74,7 @@ main (int argc, char* argv[])
{
transaction t (db->begin ());
- auto_ptr<object2> o (db->load<object2> (3));
+ unique_ptr<object2> o (db->load<object2> (3));
assert (o->str_ == long_str);
t.commit ();
}
@@ -90,7 +92,7 @@ main (int argc, char* argv[])
{
transaction t (db->begin ());
- auto_ptr<object2> o (db->load<object2> (3));
+ unique_ptr<object2> o (db->load<object2> (3));
assert (o->str_ == longer_str);
t.commit ();
}
@@ -102,7 +104,7 @@ main (int argc, char* argv[])
typedef mysql::query<object1> query;
typedef odb::result<object1> result;
- auto_ptr<database> db (create_specific_database<database> (argc, argv));
+ unique_ptr<database> db (create_specific_database<database> (argc, argv));
// Run persist/query so that the initial bindings are established
// (version == 0).
@@ -157,7 +159,7 @@ main (int argc, char* argv[])
// Test containers.
//
{
- auto_ptr<database> db (create_specific_database<database> (argc, argv));
+ unique_ptr<database> db (create_specific_database<database> (argc, argv));
// Use different connections to persist and load the object.
//
@@ -175,7 +177,7 @@ main (int argc, char* argv[])
{
transaction t (c2->begin ());
- auto_ptr<container> p (db->load<container> (1));
+ unique_ptr<container> p (db->load<container> (1));
t.commit ();
assert (p->vec_ == o.vec_);
diff --git a/mysql/truncation/makefile b/mysql/truncation/makefile
deleted file mode 100644
index 358a136..0000000
--- a/mysql/truncation/makefile
+++ /dev/null
@@ -1,107 +0,0 @@
-# file : mysql/truncation/makefile
-# license : GNU GPL v2; see accompanying LICENSE file
-
-include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
-
-cxx_tun := driver.cxx
-odb_hdr := test.hxx
-genf := $(call odb-gen,$(odb_hdr))
-gen := $(addprefix $(out_base)/,$(genf))
-cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) $(filter %.o,$(gen:.cxx=.o))
-cxx_od := $(cxx_obj:.o=.o.d)
-
-common.l := $(out_root)/libcommon/common/common.l
-common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options
-
-# Import.
-#
-$(call import,\
- $(scf_root)/import/odb/stub.make,\
- odb: odb,odb-rules: odb_rules)
-
-# Build.
-#
-$(driver): $(cxx_obj) $(common.l)
-$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base)
-$(cxx_obj) $(cxx_od): $(common.l.cpp-options)
-
-$(gen): $(odb)
-$(gen): odb := $(odb)
-$(gen) $(dist): export odb_options += --database mysql --default-database \
-common --generate-schema --generate-query --table-prefix mysql_truncation_
-$(gen): cpp_options := -I$(src_base)
-$(gen): $(common.l.cpp-options)
-
-$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
-
-# Alias for default target.
-#
-$(out_base)/: $(driver)
-
-# Dist
-#
-$(dist): sources := $(cxx_tun)
-$(dist): headers := $(odb_hdr)
-$(dist): data_dist := test.std
-$(dist): export name := $(subst /,-,$(subst $(src_root)/mysql/,,$(src_base)))
-$(dist): export extra_dist := $(data_dist) \
-$(name)-vc8.vcproj $(name)-vc9.vcproj \
-$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters \
-$(name)-vc11.vcxproj $(name)-vc11.vcxproj.filters \
-$(name)-vc12.vcxproj $(name)-vc12.vcxproj.filters
-$(dist):
- $(call dist-data,$(sources) $(headers) $(data_dist))
- $(call meta-automake,../template/Makefile.am)
- $(call meta-vc8proj,../template/template-vc8.vcproj,$(name)-vc8.vcproj)
- $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj)
- $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj)
- $(call meta-vc11proj,../template/template-vc11.vcxproj,$(name)-vc11.vcxproj)
- $(call meta-vc12proj,../template/template-vc12.vcxproj,$(name)-vc12.vcxproj)
-
-# Test.
-#
-$(eval $(call test-rule))
-
-# Clean.
-#
-$(clean): \
- $(driver).o.clean \
- $(addsuffix .cxx.clean,$(cxx_obj)) \
- $(addsuffix .cxx.clean,$(cxx_od)) \
- $(addsuffix .hxx.clean,$(filter %.cxx,$(gen)))
- $(call message,,rm -f $(out_base)/test.out)
-
-# Generated .gitignore.
-#
-ifeq ($(out_base),$(src_base))
-$(driver): | $(out_base)/.gitignore
-
-$(out_base)/.gitignore: files := driver $(genf)
-$(clean): $(out_base)/.gitignore.clean
-
-$(call include,$(bld_root)/git/gitignore.make)
-endif
-
-# How to.
-#
-$(call include,$(bld_root)/dist.make)
-$(call include,$(bld_root)/meta/vc8proj.make)
-$(call include,$(bld_root)/meta/vc9proj.make)
-$(call include,$(bld_root)/meta/vc10proj.make)
-$(call include,$(bld_root)/meta/vc11proj.make)
-$(call include,$(bld_root)/meta/vc12proj.make)
-$(call include,$(bld_root)/meta/automake.make)
-
-$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
-ifdef cxx_standard
-$(gen): odb_options += --std $(cxx_standard)
-$(call include,$(odb_rules))
-endif
-
-$(call include,$(bld_root)/cxx/cxx-d.make)
-$(call include,$(bld_root)/cxx/cxx-o.make)
-$(call include,$(bld_root)/cxx/o-e.make)
-
-# Dependencies.
-#
-$(call import,$(src_root)/libcommon/makefile)
diff --git a/mysql/truncation/test.std b/mysql/truncation/test.std
deleted file mode 100644
index e69de29..0000000
--- a/mysql/truncation/test.std
+++ /dev/null
diff --git a/mysql/truncation/testscript b/mysql/truncation/testscript
new file mode 100644
index 0000000..b9b6792
--- /dev/null
+++ b/mysql/truncation/testscript
@@ -0,0 +1,11 @@
+# file : mysql/truncation/testscript
+# license : GNU GPL v2; see accompanying LICENSE file
+
+.include ../../database-options.testscript
+.include ../../mysql.testscript
+
++$create_schema
+
+: basics
+:
+$*