1 /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
3 * Copyright 2016 Couchbase, Inc
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 * Main function & globals for the ep_unit_test target.
22 #include <memcached/extension_loggers.h>
23 #include "programs/engine_testapp/mock_server.h"
26 #include <gtest/gtest.h>
28 #include "configuration.h"
29 #include "stored-value.h"
31 /* static storage for environment variable set by putenv(). */
32 static char allow_no_stats_env[] = "ALLOW_NO_STATS_UPDATE=yeah";
34 int main(int argc, char **argv) {
35 bool log_to_stderr = false;
36 // Parse command-line options.
38 bool invalid_argument = false;
39 while (!invalid_argument &&
40 (cmd = getopt(argc, argv, "v")) != EOF) {
46 std::cerr << "Usage: " << argv[0] << " [-v] [gtest_options...]" << std::endl
48 << " -v Verbose - Print verbose output to stderr."
49 << std::endl << std::endl;
50 invalid_argument = true;
55 putenv(allow_no_stats_env);
57 init_mock_server(log_to_stderr);
58 get_mock_server_api()->log->set_level(EXTENSION_LOG_DEBUG);
60 if (memcached_initialize_stderr_logger(get_mock_server_api) != EXTENSION_SUCCESS) {
61 std::cerr << argv[0] << ": Failed to initialize log system" << std::endl;
66 // Default number of hashtable locks is too large for TSan to
67 // track. Use the value in configuration.json (47 at time of
69 HashTable::setDefaultNumLocks(Configuration().getHtLocks());
71 ::testing::InitGoogleTest(&argc, argv);
72 return RUN_ALL_TESTS();