diff options
author | Marcin Siodelski <marcin@isc.org> | 2019-07-22 13:35:58 +0200 |
---|---|---|
committer | Marcin Siodelski <marcin@isc.org> | 2019-07-25 09:58:11 +0200 |
commit | e88273f6deb9fdbf6adf6215066e0c14bf6b88a5 (patch) | |
tree | 36f16c8b29f43eb5ee74e1ea476ea62f2f0ff09e /src/lib/dhcpsrv/testutils/mysql_generic_backend_unittest.cc | |
parent | [#680,!426] Delete embedded options when subnet gets deleted in mysql_cb. (diff) | |
download | kea-e88273f6deb9fdbf6adf6215066e0c14bf6b88a5.tar.xz kea-e88273f6deb9fdbf6adf6215066e0c14bf6b88a5.zip |
[#680,!426] Deleted embedded DHCPv6 options when subnet is deleted.
Diffstat (limited to 'src/lib/dhcpsrv/testutils/mysql_generic_backend_unittest.cc')
-rw-r--r-- | src/lib/dhcpsrv/testutils/mysql_generic_backend_unittest.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/lib/dhcpsrv/testutils/mysql_generic_backend_unittest.cc b/src/lib/dhcpsrv/testutils/mysql_generic_backend_unittest.cc new file mode 100644 index 0000000000..b45aa7e1ea --- /dev/null +++ b/src/lib/dhcpsrv/testutils/mysql_generic_backend_unittest.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include <config.h> +#include <dhcpsrv/testutils/mysql_generic_backend_unittest.h> + +using namespace isc::db; + +namespace isc { +namespace dhcp { +namespace test { + +MySqlGenericBackendTest::MySqlGenericBackendTest() + : GenericBackendTest() { +} + +size_t +MySqlGenericBackendTest::countRows(MySqlConnection& conn, const std::string& table) const { + // Execute a simple select query on all rows. + std::string query = "SELECT * FROM " + table; + auto status = mysql_query(conn.mysql_, query.c_str()); + if (status != 0) { + ADD_FAILURE() << "Query failed: " << mysql_error(conn.mysql_); + return (0); + } + + // Get the number of rows returned and free the result. + MYSQL_RES * res = mysql_store_result(conn.mysql_); + unsigned numrows = static_cast<unsigned>(mysql_num_rows(res)); + mysql_free_result(res); + + return (numrows); +} + + +} // end of namespace isc::dhcp::test +} // end of namespace isc::dhcp +} // end of namespace isc |