http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/84d1e166/third_party/src/tmb/third_party/gflags/test/gflags_unittest.cc ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/test/gflags_unittest.cc b/third_party/src/tmb/third_party/gflags/test/gflags_unittest.cc deleted file mode 100644 index 80f7398..0000000 --- a/third_party/src/tmb/third_party/gflags/test/gflags_unittest.cc +++ /dev/null @@ -1,1536 +0,0 @@ -// Copyright (c) 2005, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// --- -// -// For now, this unit test does not cover all features of -// gflags.cc - -#include "config_for_unittests.h" -#include <gflags/gflags.h> - -#include <math.h> // for isinf() and isnan() -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#ifdef HAVE_UNISTD_H -# include <unistd.h> // for unlink() -#endif -#include <vector> -#include <string> -#include "util.h" -TEST_INIT -EXPECT_DEATH_INIT - -// I don't actually use this header file, but #include it under the -// old location to make sure that the include-header-forwarding -// works. But don't bother on windows; the windows port is so new -// it never had the old location-names. -#ifndef _MSC_VER -#include <gflags/gflags_completions.h> -void (*unused_fn)() = &GFLAGS_NAMESPACE::HandleCommandLineCompletions; -#endif - -using std::string; -using std::vector; -using GFLAGS_NAMESPACE::int32; -using GFLAGS_NAMESPACE::FlagRegisterer; -using GFLAGS_NAMESPACE::StringFromEnv; -using GFLAGS_NAMESPACE::RegisterFlagValidator; -using GFLAGS_NAMESPACE::CommandLineFlagInfo; -using GFLAGS_NAMESPACE::GetAllFlags; - -DEFINE_string(test_tmpdir, "", "Dir we use for temp files"); -DEFINE_string(srcdir, StringFromEnv("SRCDIR", "."), "Source-dir root, needed to find gflags_unittest_flagfile"); - -DECLARE_string(tryfromenv); // in gflags.cc - -DEFINE_bool(test_bool, false, "tests bool-ness"); -DEFINE_int32(test_int32, -1, ""); -DEFINE_int64(test_int64, -2, ""); -DEFINE_uint64(test_uint64, 2, ""); -DEFINE_double(test_double, -1.0, ""); -DEFINE_string(test_string, "initial", ""); - -// -// The below ugliness gets some additional code coverage in the -helpxml -// and -helpmatch test cases having to do with string lengths and formatting -// -DEFINE_bool(test_bool_with_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_long_name, - false, - "extremely_extremely_extremely_extremely_extremely_extremely_extremely_extremely_long_meaning"); - -DEFINE_string(test_str1, "initial", ""); -DEFINE_string(test_str2, "initial", ""); -DEFINE_string(test_str3, "initial", ""); - -// This is used to test setting tryfromenv manually -DEFINE_string(test_tryfromenv, "initial", ""); - -// Don't try this at home! -static int changeable_var = 12; -DEFINE_int32(changeable_var, ++changeable_var, ""); - -static int changeable_bool_var = 8008; -DEFINE_bool(changeable_bool_var, ++changeable_bool_var == 8009, ""); - -static int changeable_string_var = 0; -static string ChangeableString() { - char r[] = {static_cast<char>('0' + ++changeable_string_var), '\0'}; - return r; -} -DEFINE_string(changeable_string_var, ChangeableString(), ""); - -// These are never used in this unittest, but can be used by -// gflags_unittest.sh when it needs to specify flags -// that are legal for gflags_unittest but don't need to -// be a particular value. -DEFINE_bool(unused_bool, true, "unused bool-ness"); -DEFINE_int32(unused_int32, -1001, ""); -DEFINE_int64(unused_int64, -2001, ""); -DEFINE_uint64(unused_uint64, 2000, ""); -DEFINE_double(unused_double, -1000.0, ""); -DEFINE_string(unused_string, "unused", ""); - -// These flags are used by gflags_unittest.sh -DEFINE_bool(changed_bool1, false, "changed"); -DEFINE_bool(changed_bool2, false, "changed"); -DEFINE_bool(long_helpstring, false, - "This helpstring goes on forever and ever and ever and ever and " - "ever and ever and ever and ever and ever and ever and ever and " - "ever and ever and ever and ever and ever and ever and ever and " - "ever and ever and ever and ever and ever and ever and ever and " - "ever and ever and ever and ever and ever and ever and ever and " - "ever and ever and ever and ever and ever and ever and ever and " - "ever and ever and ever and ever and ever and ever and ever and " - "ever and ever and ever and ever and ever and ever and ever and " - "ever and ever and ever and ever and ever and ever and ever and " - "ever and ever and ever and ever and ever and ever and ever and " - "ever. This is the end of a long helpstring"); - - -static bool AlwaysFail(const char* flag, bool value) { return value == false; } -DEFINE_bool(always_fail, false, "will fail to validate when you set it"); -DEFINE_validator(always_fail, AlwaysFail); - -// See the comment by GetAllFlags in gflags.h -static bool DeadlockIfCantLockInValidators(const char* flag, bool value) { - if (!value) { - return true; - } - vector<CommandLineFlagInfo> dummy; - GetAllFlags(&dummy); - return true; -} -DEFINE_bool(deadlock_if_cant_lock, - false, - "will deadlock if set to true and " - "if locking of registry in validators fails."); -DEFINE_validator(deadlock_if_cant_lock, DeadlockIfCantLockInValidators); - -#define MAKEFLAG(x) DEFINE_int32(test_flag_num##x, x, "Test flag") - -// Define 10 flags -#define MAKEFLAG10(x) \ - MAKEFLAG(x##0); \ - MAKEFLAG(x##1); \ - MAKEFLAG(x##2); \ - MAKEFLAG(x##3); \ - MAKEFLAG(x##4); \ - MAKEFLAG(x##5); \ - MAKEFLAG(x##6); \ - MAKEFLAG(x##7); \ - MAKEFLAG(x##8); \ - MAKEFLAG(x##9) - -// Define 100 flags -#define MAKEFLAG100(x) \ - MAKEFLAG10(x##0); \ - MAKEFLAG10(x##1); \ - MAKEFLAG10(x##2); \ - MAKEFLAG10(x##3); \ - MAKEFLAG10(x##4); \ - MAKEFLAG10(x##5); \ - MAKEFLAG10(x##6); \ - MAKEFLAG10(x##7); \ - MAKEFLAG10(x##8); \ - MAKEFLAG10(x##9) - -// Define a bunch of command-line flags. Each occurrence of the MAKEFLAG100 -// macro defines 100 integer flags. This lets us test the effect of having -// many flags on startup time. -MAKEFLAG100(1); -MAKEFLAG100(2); -MAKEFLAG100(3); -MAKEFLAG100(4); -MAKEFLAG100(5); -MAKEFLAG100(6); -MAKEFLAG100(7); -MAKEFLAG100(8); -MAKEFLAG100(9); -MAKEFLAG100(10); -MAKEFLAG100(11); -MAKEFLAG100(12); -MAKEFLAG100(13); -MAKEFLAG100(14); -MAKEFLAG100(15); - -#undef MAKEFLAG100 -#undef MAKEFLAG10 -#undef MAKEFLAG - -// This is a pseudo-flag -- we want to register a flag with a filename -// at the top level, but there is no way to do this except by faking -// the filename. -namespace fLI { - static const int32 FLAGS_nonotldflag1 = 12; - int32 FLAGS_tldflag1 = FLAGS_nonotldflag1; - int32 FLAGS_notldflag1 = FLAGS_nonotldflag1; - static FlagRegisterer o_tldflag1( - "tldflag1", "int32", - "should show up in --helpshort", "gflags_unittest.cc", - &FLAGS_tldflag1, &FLAGS_notldflag1); -} -using fLI::FLAGS_tldflag1; - -namespace fLI { - static const int32 FLAGS_nonotldflag2 = 23; - int32 FLAGS_tldflag2 = FLAGS_nonotldflag2; - int32 FLAGS_notldflag2 = FLAGS_nonotldflag2; - static FlagRegisterer o_tldflag2( - "tldflag2", "int32", - "should show up in --helpshort", "gflags_unittest.", - &FLAGS_tldflag2, &FLAGS_notldflag2); -} -using fLI::FLAGS_tldflag2; - -namespace GFLAGS_NAMESPACE { - -namespace { - - -static string TmpFile(const string& basename) { -#ifdef _MSC_VER - return FLAGS_test_tmpdir + "\\" + basename; -#else - return FLAGS_test_tmpdir + "/" + basename; -#endif -} - -// Returns the definition of the --flagfile flag to be used in the tests. -// Must be called after ParseCommandLineFlags(). -static const char* GetFlagFileFlag() { -#ifdef _MSC_VER - static const string flagfile = FLAGS_srcdir + "\\gflags_unittest_flagfile"; -#else - static const string flagfile = FLAGS_srcdir + "/gflags_unittest_flagfile"; -#endif - static const string flagfile_flag = string("--flagfile=") + flagfile; - return flagfile_flag.c_str(); -} - - -// Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a -// compiler error iff T1 and T2 are different types. -template <typename T1, typename T2> -struct CompileAssertTypesEqual; - -template <typename T> -struct CompileAssertTypesEqual<T, T> { -}; - - -template <typename Expected, typename Actual> -void AssertIsType(Actual& x) { - CompileAssertTypesEqual<Expected, Actual>(); -} - -// Verify all the flags are the right type. -TEST(FlagTypes, FlagTypes) { - AssertIsType<bool>(FLAGS_test_bool); - AssertIsType<int32>(FLAGS_test_int32); - AssertIsType<int64>(FLAGS_test_int64); - AssertIsType<uint64>(FLAGS_test_uint64); - AssertIsType<double>(FLAGS_test_double); - AssertIsType<string>(FLAGS_test_string); -} - -#ifdef GTEST_HAS_DEATH_TEST -// Death tests for "help" options. -// -// The help system automatically calls gflags_exitfunc(1) when you specify any of -// the help-related flags ("-helpmatch", "-helpxml") so we can't test -// those mainline. - -// Tests that "-helpmatch" causes the process to die. -TEST(ReadFlagsFromStringDeathTest, HelpMatch) { - EXPECT_DEATH(ReadFlagsFromString("-helpmatch=base", GetArgv0(), true), - ""); -} - - -// Tests that "-helpxml" causes the process to die. -TEST(ReadFlagsFromStringDeathTest, HelpXml) { - EXPECT_DEATH(ReadFlagsFromString("-helpxml", GetArgv0(), true), - ""); -} -#endif - - -// A subroutine needed for testing reading flags from a string. -void TestFlagString(const string& flags, - const string& expected_string, - bool expected_bool, - int32 expected_int32, - double expected_double) { - EXPECT_TRUE(ReadFlagsFromString(flags, - GetArgv0(), - // errors are fatal - true)); - - EXPECT_EQ(expected_string, FLAGS_test_string); - EXPECT_EQ(expected_bool, FLAGS_test_bool); - EXPECT_EQ(expected_int32, FLAGS_test_int32); - EXPECT_DOUBLE_EQ(expected_double, FLAGS_test_double); -} - - -// Tests reading flags from a string. -TEST(FlagFileTest, ReadFlagsFromString) { - TestFlagString( - // Flag string - "-test_string=continued\n" - "# some comments are in order\n" - "# some\n" - " # comments\n" - "#are\n" - " #trickier\n" - "# than others\n" - "-test_bool=true\n" - " -test_int32=1\n" - "-test_double=0.0\n", - // Expected values - "continued", - true, - 1, - 0.0); - - TestFlagString( - // Flag string - "# let's make sure it can update values\n" - "-test_string=initial\n" - "-test_bool=false\n" - "-test_int32=123\n" - "-test_double=123.0\n", - // Expected values - "initial", - false, - 123, - 123.0); -} - -// Tests the filename part of the flagfile -TEST(FlagFileTest, FilenamesOurfileLast) { - FLAGS_test_string = "initial"; - FLAGS_test_bool = false; - FLAGS_test_int32 = -1; - FLAGS_test_double = -1.0; - TestFlagString( - // Flag string - "-test_string=continued\n" - "# some comments are in order\n" - "# some\n" - " # comments\n" - "#are\n" - " #trickier\n" - "# than others\n" - "not_our_filename\n" - "-test_bool=true\n" - " -test_int32=1\n" - "gflags_unittest\n" - "-test_double=1000.0\n", - // Expected values - "continued", - false, - -1, - 1000.0); -} - -TEST(FlagFileTest, FilenamesOurfileFirst) { - FLAGS_test_string = "initial"; - FLAGS_test_bool = false; - FLAGS_test_int32 = -1; - FLAGS_test_double = -1.0; - TestFlagString( - // Flag string - "-test_string=continued\n" - "# some comments are in order\n" - "# some\n" - " # comments\n" - "#are\n" - " #trickier\n" - "# than others\n" - "gflags_unittest\n" - "-test_bool=true\n" - " -test_int32=1\n" - "not_our_filename\n" - "-test_double=1000.0\n", - // Expected values - "continued", - true, - 1, - -1.0); -} - -#if defined(HAVE_FNMATCH_H) || defined(HAVE_SHLWAPI_H) // otherwise glob isn't supported -TEST(FlagFileTest, FilenamesOurfileGlob) { - FLAGS_test_string = "initial"; - FLAGS_test_bool = false; - FLAGS_test_int32 = -1; - FLAGS_test_double = -1.0; - TestFlagString( - // Flag string - "-test_string=continued\n" - "# some comments are in order\n" - "# some\n" - " # comments\n" - "#are\n" - " #trickier\n" - "# than others\n" - "*flags*\n" - "-test_bool=true\n" - " -test_int32=1\n" - "flags\n" - "-test_double=1000.0\n", - // Expected values - "continued", - true, - 1, - -1.0); -} - -TEST(FlagFileTest, FilenamesOurfileInBigList) { - FLAGS_test_string = "initial"; - FLAGS_test_bool = false; - FLAGS_test_int32 = -1; - FLAGS_test_double = -1.0; - TestFlagString( - // Flag string - "-test_string=continued\n" - "# some comments are in order\n" - "# some\n" - " # comments\n" - "#are\n" - " #trickier\n" - "# than others\n" - "*first* *flags* *third*\n" - "-test_bool=true\n" - " -test_int32=1\n" - "flags\n" - "-test_double=1000.0\n", - // Expected values - "continued", - true, - 1, - -1.0); -} -#endif // defined(HAVE_FNMATCH_H) || defined(HAVE_SHLWAPI_H) - -// Tests that a failed flag-from-string read keeps flags at default values -TEST(FlagFileTest, FailReadFlagsFromString) { - FLAGS_test_int32 = 119; - string flags("# let's make sure it can update values\n" - "-test_string=non_initial\n" - "-test_bool=false\n" - "-test_int32=123\n" - "-test_double=illegal\n"); - - EXPECT_FALSE(ReadFlagsFromString(flags, - GetArgv0(), - // errors are fatal - false)); - - EXPECT_EQ(119, FLAGS_test_int32); - EXPECT_EQ("initial", FLAGS_test_string); -} - -// Tests that flags can be set to ordinary values. -TEST(SetFlagValueTest, OrdinaryValues) { - EXPECT_EQ("initial", FLAGS_test_str1); - - SetCommandLineOptionWithMode("test_str1", "second", SET_FLAG_IF_DEFAULT); - EXPECT_EQ("second", FLAGS_test_str1); // set; was default - - SetCommandLineOptionWithMode("test_str1", "third", SET_FLAG_IF_DEFAULT); - EXPECT_EQ("second", FLAGS_test_str1); // already set once - - FLAGS_test_str1 = "initial"; - SetCommandLineOptionWithMode("test_str1", "third", SET_FLAG_IF_DEFAULT); - EXPECT_EQ("initial", FLAGS_test_str1); // still already set before - - SetCommandLineOptionWithMode("test_str1", "third", SET_FLAGS_VALUE); - EXPECT_EQ("third", FLAGS_test_str1); // changed value - - SetCommandLineOptionWithMode("test_str1", "fourth", SET_FLAGS_DEFAULT); - EXPECT_EQ("third", FLAGS_test_str1); - // value not changed (already set before) - - EXPECT_EQ("initial", FLAGS_test_str2); - - SetCommandLineOptionWithMode("test_str2", "second", SET_FLAGS_DEFAULT); - EXPECT_EQ("second", FLAGS_test_str2); // changed (was default) - - FLAGS_test_str2 = "extra"; - EXPECT_EQ("extra", FLAGS_test_str2); - - FLAGS_test_str2 = "second"; - SetCommandLineOptionWithMode("test_str2", "third", SET_FLAGS_DEFAULT); - EXPECT_EQ("third", FLAGS_test_str2); // still changed (was equal to default) - - SetCommandLineOptionWithMode("test_str2", "fourth", SET_FLAG_IF_DEFAULT); - EXPECT_EQ("fourth", FLAGS_test_str2); // changed (was default) - - EXPECT_EQ("initial", FLAGS_test_str3); - - SetCommandLineOptionWithMode("test_str3", "second", SET_FLAGS_DEFAULT); - EXPECT_EQ("second", FLAGS_test_str3); // changed - - FLAGS_test_str3 = "third"; - SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAGS_DEFAULT); - EXPECT_EQ("third", FLAGS_test_str3); // not changed (was set) - - SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAG_IF_DEFAULT); - EXPECT_EQ("third", FLAGS_test_str3); // not changed (was set) - - SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAGS_VALUE); - EXPECT_EQ("fourth", FLAGS_test_str3); // changed value -} - - -// Tests that flags can be set to exceptional values. -// Note: apparently MINGW doesn't parse inf and nan correctly: -// http://www.mail-archive.com/bug-gnulib@gnu.org/msg09573.html -// This url says FreeBSD also has a problem, but I didn't see that. -TEST(SetFlagValueTest, ExceptionalValues) { -#if defined(isinf) && !defined(__MINGW32__) - EXPECT_EQ("test_double set to inf\n", - SetCommandLineOption("test_double", "inf")); - EXPECT_INF(FLAGS_test_double); - - EXPECT_EQ("test_double set to inf\n", - SetCommandLineOption("test_double", "INF")); - EXPECT_INF(FLAGS_test_double); -#endif - - // set some bad values - EXPECT_EQ("", - SetCommandLineOption("test_double", "0.1xxx")); - EXPECT_EQ("", - SetCommandLineOption("test_double", " ")); - EXPECT_EQ("", - SetCommandLineOption("test_double", "")); -#if defined(isinf) && !defined(__MINGW32__) - EXPECT_EQ("test_double set to -inf\n", - SetCommandLineOption("test_double", "-inf")); - EXPECT_INF(FLAGS_test_double); - EXPECT_GT(0, FLAGS_test_double); -#endif - -#if defined(isnan) && !defined(__MINGW32__) - EXPECT_EQ("test_double set to nan\n", - SetCommandLineOption("test_double", "NaN")); - EXPECT_NAN(FLAGS_test_double); -#endif -} - -// Tests that integer flags can be specified in many ways -TEST(SetFlagValueTest, DifferentRadices) { - EXPECT_EQ("test_int32 set to 12\n", - SetCommandLineOption("test_int32", "12")); - - EXPECT_EQ("test_int32 set to 16\n", - SetCommandLineOption("test_int32", "0x10")); - - EXPECT_EQ("test_int32 set to 34\n", - SetCommandLineOption("test_int32", "0X22")); - - // Leading 0 is *not* octal; it's still decimal - EXPECT_EQ("test_int32 set to 10\n", - SetCommandLineOption("test_int32", "010")); -} - -// Tests what happens when you try to set a flag to an illegal value -TEST(SetFlagValueTest, IllegalValues) { - FLAGS_test_bool = true; - FLAGS_test_int32 = 119; - FLAGS_test_int64 = 1191; - FLAGS_test_uint64 = 11911; - - EXPECT_EQ("", - SetCommandLineOption("test_bool", "12")); - - EXPECT_EQ("", - SetCommandLineOption("test_int32", "7000000000000")); - - EXPECT_EQ("", - SetCommandLineOption("test_uint64", "-1")); - - EXPECT_EQ("", - SetCommandLineOption("test_int64", "not a number!")); - - // Test the empty string with each type of input - EXPECT_EQ("", SetCommandLineOption("test_bool", "")); - EXPECT_EQ("", SetCommandLineOption("test_int32", "")); - EXPECT_EQ("", SetCommandLineOption("test_int64", "")); - EXPECT_EQ("", SetCommandLineOption("test_uint64", "")); - EXPECT_EQ("", SetCommandLineOption("test_double", "")); - EXPECT_EQ("test_string set to \n", SetCommandLineOption("test_string", "")); - - EXPECT_TRUE(FLAGS_test_bool); - EXPECT_EQ(119, FLAGS_test_int32); - EXPECT_EQ(1191, FLAGS_test_int64); - EXPECT_EQ(11911, FLAGS_test_uint64); -} - - -// Tests that we only evaluate macro args once -TEST(MacroArgs, EvaluateOnce) { - EXPECT_EQ(13, FLAGS_changeable_var); - // Make sure we don't ++ the value somehow, when evaluating the flag. - EXPECT_EQ(13, FLAGS_changeable_var); - // Make sure the macro only evaluated this var once. - EXPECT_EQ(13, changeable_var); - // Make sure the actual value and default value are the same - SetCommandLineOptionWithMode("changeable_var", "21", SET_FLAG_IF_DEFAULT); - EXPECT_EQ(21, FLAGS_changeable_var); -} - -TEST(MacroArgs, EvaluateOnceBool) { - EXPECT_TRUE(FLAGS_changeable_bool_var); - EXPECT_TRUE(FLAGS_changeable_bool_var); - EXPECT_EQ(8009, changeable_bool_var); - SetCommandLineOptionWithMode("changeable_bool_var", "false", - SET_FLAG_IF_DEFAULT); - EXPECT_FALSE(FLAGS_changeable_bool_var); -} - -TEST(MacroArgs, EvaluateOnceStrings) { - EXPECT_EQ("1", FLAGS_changeable_string_var); - EXPECT_EQ("1", FLAGS_changeable_string_var); - EXPECT_EQ(1, changeable_string_var); - SetCommandLineOptionWithMode("changeable_string_var", "different", - SET_FLAG_IF_DEFAULT); - EXPECT_EQ("different", FLAGS_changeable_string_var); -} - -// Tests that the FooFromEnv does the right thing -TEST(FromEnvTest, LegalValues) { - setenv("BOOL_VAL1", "true", 1); - setenv("BOOL_VAL2", "false", 1); - setenv("BOOL_VAL3", "1", 1); - setenv("BOOL_VAL4", "F", 1); - EXPECT_TRUE(BoolFromEnv("BOOL_VAL1", false)); - EXPECT_FALSE(BoolFromEnv("BOOL_VAL2", true)); - EXPECT_TRUE(BoolFromEnv("BOOL_VAL3", false)); - EXPECT_FALSE(BoolFromEnv("BOOL_VAL4", true)); - EXPECT_TRUE(BoolFromEnv("BOOL_VAL_UNKNOWN", true)); - EXPECT_FALSE(BoolFromEnv("BOOL_VAL_UNKNOWN", false)); - - setenv("INT_VAL1", "1", 1); - setenv("INT_VAL2", "-1", 1); - EXPECT_EQ(1, Int32FromEnv("INT_VAL1", 10)); - EXPECT_EQ(-1, Int32FromEnv("INT_VAL2", 10)); - EXPECT_EQ(10, Int32FromEnv("INT_VAL_UNKNOWN", 10)); - - setenv("INT_VAL3", "1099511627776", 1); - EXPECT_EQ(1, Int64FromEnv("INT_VAL1", 20)); - EXPECT_EQ(-1, Int64FromEnv("INT_VAL2", 20)); - EXPECT_EQ(1099511627776LL, Int64FromEnv("INT_VAL3", 20)); - EXPECT_EQ(20, Int64FromEnv("INT_VAL_UNKNOWN", 20)); - - EXPECT_EQ(1, Uint64FromEnv("INT_VAL1", 30)); - EXPECT_EQ(1099511627776ULL, Uint64FromEnv("INT_VAL3", 30)); - EXPECT_EQ(30, Uint64FromEnv("INT_VAL_UNKNOWN", 30)); - - // I pick values here that can be easily represented exactly in floating-point - setenv("DOUBLE_VAL1", "0.0", 1); - setenv("DOUBLE_VAL2", "1.0", 1); - setenv("DOUBLE_VAL3", "-1.0", 1); - EXPECT_EQ(0.0, DoubleFromEnv("DOUBLE_VAL1", 40.0)); - EXPECT_EQ(1.0, DoubleFromEnv("DOUBLE_VAL2", 40.0)); - EXPECT_EQ(-1.0, DoubleFromEnv("DOUBLE_VAL3", 40.0)); - EXPECT_EQ(40.0, DoubleFromEnv("DOUBLE_VAL_UNKNOWN", 40.0)); - - setenv("STRING_VAL1", "", 1); - setenv("STRING_VAL2", "my happy string!", 1); - EXPECT_STREQ("", StringFromEnv("STRING_VAL1", "unknown")); - EXPECT_STREQ("my happy string!", StringFromEnv("STRING_VAL2", "unknown")); - EXPECT_STREQ("unknown", StringFromEnv("STRING_VAL_UNKNOWN", "unknown")); -} - -#ifdef GTEST_HAS_DEATH_TEST -// Tests that the FooFromEnv dies on parse-error -TEST(FromEnvDeathTest, IllegalValues) { - setenv("BOOL_BAD1", "so true!", 1); - setenv("BOOL_BAD2", "", 1); - EXPECT_DEATH(BoolFromEnv("BOOL_BAD1", false), "error parsing env variable"); - EXPECT_DEATH(BoolFromEnv("BOOL_BAD2", true), "error parsing env variable"); - - setenv("INT_BAD1", "one", 1); - setenv("INT_BAD2", "100000000000000000", 1); - setenv("INT_BAD3", "0xx10", 1); - setenv("INT_BAD4", "", 1); - EXPECT_DEATH(Int32FromEnv("INT_BAD1", 10), "error parsing env variable"); - EXPECT_DEATH(Int32FromEnv("INT_BAD2", 10), "error parsing env variable"); - EXPECT_DEATH(Int32FromEnv("INT_BAD3", 10), "error parsing env variable"); - EXPECT_DEATH(Int32FromEnv("INT_BAD4", 10), "error parsing env variable"); - - setenv("BIGINT_BAD1", "18446744073709551616000", 1); - EXPECT_DEATH(Int64FromEnv("INT_BAD1", 20), "error parsing env variable"); - EXPECT_DEATH(Int64FromEnv("INT_BAD3", 20), "error parsing env variable"); - EXPECT_DEATH(Int64FromEnv("INT_BAD4", 20), "error parsing env variable"); - EXPECT_DEATH(Int64FromEnv("BIGINT_BAD1", 200), "error parsing env variable"); - - setenv("BIGINT_BAD2", "-1", 1); - EXPECT_DEATH(Uint64FromEnv("INT_BAD1", 30), "error parsing env variable"); - EXPECT_DEATH(Uint64FromEnv("INT_BAD3", 30), "error parsing env variable"); - EXPECT_DEATH(Uint64FromEnv("INT_BAD4", 30), "error parsing env variable"); - EXPECT_DEATH(Uint64FromEnv("BIGINT_BAD1", 30), "error parsing env variable"); - // TODO(csilvers): uncomment this when we disallow negative numbers for uint64 -#if 0 - EXPECT_DEATH(Uint64FromEnv("BIGINT_BAD2", 30), "error parsing env variable"); -#endif - - setenv("DOUBLE_BAD1", "0.0.0", 1); - setenv("DOUBLE_BAD2", "", 1); - EXPECT_DEATH(DoubleFromEnv("DOUBLE_BAD1", 40.0), "error parsing env variable"); - EXPECT_DEATH(DoubleFromEnv("DOUBLE_BAD2", 40.0), "error parsing env variable"); -} -#endif - - -// Tests that FlagSaver can save the states of string flags. -TEST(FlagSaverTest, CanSaveStringFlagStates) { - // 1. Initializes the flags. - - // State of flag test_str1: - // default value - "initial" - // current value - "initial" - // not set - true - - SetCommandLineOptionWithMode("test_str2", "second", SET_FLAGS_VALUE); - // State of flag test_str2: - // default value - "initial" - // current value - "second" - // not set - false - - SetCommandLineOptionWithMode("test_str3", "second", SET_FLAGS_DEFAULT); - // State of flag test_str3: - // default value - "second" - // current value - "second" - // not set - true - - // 2. Saves the flag states. - - { - FlagSaver fs; - - // 3. Modifies the flag states. - - SetCommandLineOptionWithMode("test_str1", "second", SET_FLAGS_VALUE); - EXPECT_EQ("second", FLAGS_test_str1); - // State of flag test_str1: - // default value - "second" - // current value - "second" - // not set - true - - SetCommandLineOptionWithMode("test_str2", "third", SET_FLAGS_DEFAULT); - EXPECT_EQ("second", FLAGS_test_str2); - // State of flag test_str2: - // default value - "third" - // current value - "second" - // not set - false - - SetCommandLineOptionWithMode("test_str3", "third", SET_FLAGS_VALUE); - EXPECT_EQ("third", FLAGS_test_str3); - // State of flag test_str1: - // default value - "second" - // current value - "third" - // not set - false - - // 4. Restores the flag states. - } - - // 5. Verifies that the states were restored. - - // Verifies that the value of test_str1 was restored. - EXPECT_EQ("initial", FLAGS_test_str1); - // Verifies that the "not set" attribute of test_str1 was restored to true. - SetCommandLineOptionWithMode("test_str1", "second", SET_FLAG_IF_DEFAULT); - EXPECT_EQ("second", FLAGS_test_str1); - - // Verifies that the value of test_str2 was restored. - EXPECT_EQ("second", FLAGS_test_str2); - // Verifies that the "not set" attribute of test_str2 was restored to false. - SetCommandLineOptionWithMode("test_str2", "fourth", SET_FLAG_IF_DEFAULT); - EXPECT_EQ("second", FLAGS_test_str2); - - // Verifies that the value of test_str3 was restored. - EXPECT_EQ("second", FLAGS_test_str3); - // Verifies that the "not set" attribute of test_str3 was restored to true. - SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAG_IF_DEFAULT); - EXPECT_EQ("fourth", FLAGS_test_str3); -} - - -// Tests that FlagSaver can save the values of various-typed flags. -TEST(FlagSaverTest, CanSaveVariousTypedFlagValues) { - // Initializes the flags. - FLAGS_test_bool = false; - FLAGS_test_int32 = -1; - FLAGS_test_int64 = -2; - FLAGS_test_uint64 = 3; - FLAGS_test_double = 4.0; - FLAGS_test_string = "good"; - - // Saves the flag states. - { - FlagSaver fs; - - // Modifies the flags. - FLAGS_test_bool = true; - FLAGS_test_int32 = -5; - FLAGS_test_int64 = -6; - FLAGS_test_uint64 = 7; - FLAGS_test_double = 8.0; - FLAGS_test_string = "bad"; - - // Restores the flag states. - } - - // Verifies the flag values were restored. - EXPECT_FALSE(FLAGS_test_bool); - EXPECT_EQ(-1, FLAGS_test_int32); - EXPECT_EQ(-2, FLAGS_test_int64); - EXPECT_EQ(3, FLAGS_test_uint64); - EXPECT_DOUBLE_EQ(4.0, FLAGS_test_double); - EXPECT_EQ("good", FLAGS_test_string); -} - -TEST(GetAllFlagsTest, BaseTest) { - vector<CommandLineFlagInfo> flags; - GetAllFlags(&flags); - bool found_test_bool = false; - vector<CommandLineFlagInfo>::const_iterator i; - for (i = flags.begin(); i != flags.end(); ++i) { - if (i->name == "test_bool") { - found_test_bool = true; - EXPECT_EQ(i->type, "bool"); - EXPECT_EQ(i->default_value, "false"); - EXPECT_EQ(i->flag_ptr, &FLAGS_test_bool); - break; - } - } - EXPECT_TRUE(found_test_bool); -} - -TEST(ShowUsageWithFlagsTest, BaseTest) { - // TODO(csilvers): test this by allowing output other than to stdout. - // Not urgent since this functionality is tested via - // gflags_unittest.sh, though only through use of --help. -} - -TEST(ShowUsageWithFlagsRestrictTest, BaseTest) { - // TODO(csilvers): test this by allowing output other than to stdout. - // Not urgent since this functionality is tested via - // gflags_unittest.sh, though only through use of --helpmatch. -} - -// Note: all these argv-based tests depend on SetArgv being called -// before ParseCommandLineFlags() in main(), below. -TEST(GetArgvsTest, BaseTest) { - vector<string> argvs = GetArgvs(); - EXPECT_EQ(4, argvs.size()); - EXPECT_EQ("/test/argv/for/gflags_unittest", argvs[0]); - EXPECT_EQ("argv 2", argvs[1]); - EXPECT_EQ("3rd argv", argvs[2]); - EXPECT_EQ("argv #4", argvs[3]); -} - -TEST(GetArgvTest, BaseTest) { - EXPECT_STREQ("/test/argv/for/gflags_unittest " - "argv 2 3rd argv argv #4", GetArgv()); -} - -TEST(GetArgv0Test, BaseTest) { - EXPECT_STREQ("/test/argv/for/gflags_unittest", GetArgv0()); -} - -TEST(GetArgvSumTest, BaseTest) { - // This number is just the sum of the ASCII values of all the chars - // in GetArgv(). - EXPECT_EQ(4904, GetArgvSum()); -} - -TEST(ProgramInvocationNameTest, BaseTest) { - EXPECT_STREQ("/test/argv/for/gflags_unittest", - ProgramInvocationName()); -} - -TEST(ProgramInvocationShortNameTest, BaseTest) { - EXPECT_STREQ("gflags_unittest", ProgramInvocationShortName()); -} - -TEST(ProgramUsageTest, BaseTest) { // Depends on 1st arg to ParseCommandLineFlags() - EXPECT_STREQ("/test/argv/for/gflags_unittest: " - "<useless flag> [...]\nDoes something useless.\n", - ProgramUsage()); -} - -TEST(GetCommandLineOptionTest, NameExistsAndIsDefault) { - string value("will be changed"); - bool r = GetCommandLineOption("test_bool", &value); - EXPECT_TRUE(r); - EXPECT_EQ("false", value); - - r = GetCommandLineOption("test_int32", &value); - EXPECT_TRUE(r); - EXPECT_EQ("-1", value); -} - -TEST(GetCommandLineOptionTest, NameExistsAndWasAssigned) { - FLAGS_test_int32 = 400; - string value("will be changed"); - const bool r = GetCommandLineOption("test_int32", &value); - EXPECT_TRUE(r); - EXPECT_EQ("400", value); -} - -TEST(GetCommandLineOptionTest, NameExistsAndWasSet) { - SetCommandLineOption("test_int32", "700"); - string value("will be changed"); - const bool r = GetCommandLineOption("test_int32", &value); - EXPECT_TRUE(r); - EXPECT_EQ("700", value); -} - -TEST(GetCommandLineOptionTest, NameExistsAndWasNotSet) { - // This doesn't set the flag's value, but rather its default value. - // is_default is still true, but the 'default' value returned has changed! - SetCommandLineOptionWithMode("test_int32", "800", SET_FLAGS_DEFAULT); - string value("will be changed"); - const bool r = GetCommandLineOption("test_int32", &value); - EXPECT_TRUE(r); - EXPECT_EQ("800", value); - EXPECT_TRUE(GetCommandLineFlagInfoOrDie("test_int32").is_default); -} - -TEST(GetCommandLineOptionTest, NameExistsAndWasConditionallySet) { - SetCommandLineOptionWithMode("test_int32", "900", SET_FLAG_IF_DEFAULT); - string value("will be changed"); - const bool r = GetCommandLineOption("test_int32", &value); - EXPECT_TRUE(r); - EXPECT_EQ("900", value); -} - -TEST(GetCommandLineOptionTest, NameDoesNotExist) { - string value("will not be changed"); - const bool r = GetCommandLineOption("test_int3210", &value); - EXPECT_FALSE(r); - EXPECT_EQ("will not be changed", value); -} - -TEST(GetCommandLineFlagInfoTest, FlagExists) { - CommandLineFlagInfo info; - bool r = GetCommandLineFlagInfo("test_int32", &info); - EXPECT_TRUE(r); - EXPECT_EQ("test_int32", info.name); - EXPECT_EQ("int32", info.type); - EXPECT_EQ("", info.description); - EXPECT_EQ("-1", info.current_value); - EXPECT_EQ("-1", info.default_value); - EXPECT_TRUE(info.is_default); - EXPECT_FALSE(info.has_validator_fn); - EXPECT_EQ(&FLAGS_test_int32, info.flag_ptr); - - FLAGS_test_bool = true; - r = GetCommandLineFlagInfo("test_bool", &info); - EXPECT_TRUE(r); - EXPECT_EQ("test_bool", info.name); - EXPECT_EQ("bool", info.type); - EXPECT_EQ("tests bool-ness", info.description); - EXPECT_EQ("true", info.current_value); - EXPECT_EQ("false", info.default_value); - EXPECT_FALSE(info.is_default); - EXPECT_FALSE(info.has_validator_fn); - EXPECT_EQ(&FLAGS_test_bool, info.flag_ptr); - - FLAGS_test_bool = false; - r = GetCommandLineFlagInfo("test_bool", &info); - EXPECT_TRUE(r); - EXPECT_EQ("test_bool", info.name); - EXPECT_EQ("bool", info.type); - EXPECT_EQ("tests bool-ness", info.description); - EXPECT_EQ("false", info.current_value); - EXPECT_EQ("false", info.default_value); - EXPECT_FALSE(info.is_default); // value is same, but flag *was* modified - EXPECT_FALSE(info.has_validator_fn); - EXPECT_EQ(&FLAGS_test_bool, info.flag_ptr); -} - -TEST(GetCommandLineFlagInfoTest, FlagDoesNotExist) { - CommandLineFlagInfo info; - // Set to some random values that GetCommandLineFlagInfo should not change - info.name = "name"; - info.type = "type"; - info.current_value = "curr"; - info.default_value = "def"; - info.filename = "/"; - info.is_default = false; - info.has_validator_fn = true; - info.flag_ptr = NULL; - bool r = GetCommandLineFlagInfo("test_int3210", &info); - EXPECT_FALSE(r); - EXPECT_EQ("name", info.name); - EXPECT_EQ("type", info.type); - EXPECT_EQ("", info.description); - EXPECT_EQ("curr", info.current_value); - EXPECT_EQ("def", info.default_value); - EXPECT_EQ("/", info.filename); - EXPECT_FALSE(info.is_default); - EXPECT_TRUE(info.has_validator_fn); - EXPECT_EQ(NULL, info.flag_ptr); -} - -TEST(GetCommandLineFlagInfoOrDieTest, FlagExistsAndIsDefault) { - CommandLineFlagInfo info; - info = GetCommandLineFlagInfoOrDie("test_int32"); - EXPECT_EQ("test_int32", info.name); - EXPECT_EQ("int32", info.type); - EXPECT_EQ("", info.description); - EXPECT_EQ("-1", info.current_value); - EXPECT_EQ("-1", info.default_value); - EXPECT_TRUE(info.is_default); - EXPECT_EQ(&FLAGS_test_int32, info.flag_ptr); - info = GetCommandLineFlagInfoOrDie("test_bool"); - EXPECT_EQ("test_bool", info.name); - EXPECT_EQ("bool", info.type); - EXPECT_EQ("tests bool-ness", info.description); - EXPECT_EQ("false", info.current_value); - EXPECT_EQ("false", info.default_value); - EXPECT_TRUE(info.is_default); - EXPECT_FALSE(info.has_validator_fn); - EXPECT_EQ(&FLAGS_test_bool, info.flag_ptr); -} - -TEST(GetCommandLineFlagInfoOrDieTest, FlagExistsAndWasAssigned) { - FLAGS_test_int32 = 400; - CommandLineFlagInfo info; - info = GetCommandLineFlagInfoOrDie("test_int32"); - EXPECT_EQ("test_int32", info.name); - EXPECT_EQ("int32", info.type); - EXPECT_EQ("", info.description); - EXPECT_EQ("400", info.current_value); - EXPECT_EQ("-1", info.default_value); - EXPECT_FALSE(info.is_default); - EXPECT_EQ(&FLAGS_test_int32, info.flag_ptr); - FLAGS_test_bool = true; - info = GetCommandLineFlagInfoOrDie("test_bool"); - EXPECT_EQ("test_bool", info.name); - EXPECT_EQ("bool", info.type); - EXPECT_EQ("tests bool-ness", info.description); - EXPECT_EQ("true", info.current_value); - EXPECT_EQ("false", info.default_value); - EXPECT_FALSE(info.is_default); - EXPECT_FALSE(info.has_validator_fn); - EXPECT_EQ(&FLAGS_test_bool, info.flag_ptr); -} - -#ifdef GTEST_HAS_DEATH_TEST -TEST(GetCommandLineFlagInfoOrDieDeathTest, FlagDoesNotExist) { - EXPECT_DEATH(GetCommandLineFlagInfoOrDie("test_int3210"), - ".*: flag test_int3210 does not exist"); -} -#endif - - -// These are lightly tested because they're deprecated. Basically, -// the tests are meant to cover how existing users use these functions, -// but not necessarily how new users could use them. -TEST(DeprecatedFunctionsTest, CommandlineFlagsIntoString) { - string s = CommandlineFlagsIntoString(); - EXPECT_NE(string::npos, s.find("--test_bool=")); -} - -TEST(DeprecatedFunctionsTest, AppendFlagsIntoFile) { - FLAGS_test_int32 = 10; // just to make the test more interesting - string filename(TmpFile("flagfile")); - unlink(filename.c_str()); // just to be safe - const bool r = AppendFlagsIntoFile(filename, "not the real argv0"); - EXPECT_TRUE(r); - - FILE* fp; - EXPECT_EQ(0, SafeFOpen(&fp, filename.c_str(), "r")); - EXPECT_TRUE(fp != NULL); - char line[8192]; - EXPECT_TRUE(fgets(line, sizeof(line)-1, fp) != NULL); // get the first line - // First line should be progname. - EXPECT_STREQ("not the real argv0\n", line); - - bool found_bool = false, found_int32 = false; - while (fgets(line, sizeof(line)-1, fp)) { - line[sizeof(line)-1] = '\0'; // just to be safe - if (strcmp(line, "--test_bool=false\n") == 0) - found_bool = true; - if (strcmp(line, "--test_int32=10\n") == 0) - found_int32 = true; - } - EXPECT_TRUE(found_int32); - EXPECT_TRUE(found_bool); - fclose(fp); -} - -TEST(DeprecatedFunctionsTest, ReadFromFlagsFile) { - FLAGS_test_int32 = -10; // just to make the test more interesting - string filename(TmpFile("flagfile2")); - unlink(filename.c_str()); // just to be safe - bool r = AppendFlagsIntoFile(filename, GetArgv0()); - EXPECT_TRUE(r); - - FLAGS_test_int32 = -11; - r = ReadFromFlagsFile(filename, GetArgv0(), true); - EXPECT_TRUE(r); - EXPECT_EQ(-10, FLAGS_test_int32); -} // unnamed namespace - -TEST(DeprecatedFunctionsTest, ReadFromFlagsFileFailure) { - FLAGS_test_int32 = -20; - string filename(TmpFile("flagfile3")); - FILE* fp; - EXPECT_EQ(0, SafeFOpen(&fp, filename.c_str(), "w")); - EXPECT_TRUE(fp != NULL); - // Note the error in the bool assignment below... - fprintf(fp, "%s\n--test_int32=-21\n--test_bool=not_a_bool!\n", GetArgv0()); - fclose(fp); - - FLAGS_test_int32 = -22; - const bool r = ReadFromFlagsFile(filename, GetArgv0(), false); - EXPECT_FALSE(r); - EXPECT_EQ(-22, FLAGS_test_int32); // the -21 from the flagsfile didn't take -} - -TEST(FlagsSetBeforeInitTest, TryFromEnv) { - EXPECT_EQ("pre-set", FLAGS_test_tryfromenv); -} - -// The following test case verifies that ParseCommandLineFlags() and -// ParseCommandLineNonHelpFlags() uses the last definition of a flag -// in case it's defined more than once. - -DEFINE_int32(test_flag, -1, "used for testing gflags.cc"); - -// Parses and returns the --test_flag flag. -// If with_help is true, calls ParseCommandLineFlags; otherwise calls -// ParseCommandLineNonHelpFlags. -int32 ParseTestFlag(bool with_help, int argc, const char** const_argv) { - FlagSaver fs; // Restores the flags before returning. - - // Makes a copy of the input array s.t. it can be reused - // (ParseCommandLineFlags() will alter the array). - char** const argv_save = new char*[argc + 1]; - char** argv = argv_save; - memcpy(argv, const_argv, sizeof(*argv)*(argc + 1)); - - if (with_help) { - ParseCommandLineFlags(&argc, &argv, true); - } else { - ParseCommandLineNonHelpFlags(&argc, &argv, true); - } - - delete[] argv_save; - return FLAGS_test_flag; -} - -TEST(ParseCommandLineFlagsUsesLastDefinitionTest, - WhenFlagIsDefinedTwiceOnCommandLine) { - const char* argv[] = { - "my_test", - "--test_flag=1", - "--test_flag=2", - NULL, - }; - - EXPECT_EQ(2, ParseTestFlag(true, arraysize(argv) - 1, argv)); - EXPECT_EQ(2, ParseTestFlag(false, arraysize(argv) - 1, argv)); -} - -TEST(ParseCommandLineFlagsUsesLastDefinitionTest, - WhenFlagIsDefinedTwiceInFlagFile) { - const char* argv[] = { - "my_test", - GetFlagFileFlag(), - NULL, - }; - - EXPECT_EQ(2, ParseTestFlag(true, arraysize(argv) - 1, argv)); - EXPECT_EQ(2, ParseTestFlag(false, arraysize(argv) - 1, argv)); -} - -TEST(ParseCommandLineFlagsUsesLastDefinitionTest, - WhenFlagIsDefinedInCommandLineAndThenFlagFile) { - const char* argv[] = { - "my_test", - "--test_flag=0", - GetFlagFileFlag(), - NULL, - }; - - EXPECT_EQ(2, ParseTestFlag(true, arraysize(argv) - 1, argv)); - EXPECT_EQ(2, ParseTestFlag(false, arraysize(argv) - 1, argv)); -} - -TEST(ParseCommandLineFlagsUsesLastDefinitionTest, - WhenFlagIsDefinedInFlagFileAndThenCommandLine) { - const char* argv[] = { - "my_test", - GetFlagFileFlag(), - "--test_flag=3", - NULL, - }; - - EXPECT_EQ(3, ParseTestFlag(true, arraysize(argv) - 1, argv)); - EXPECT_EQ(3, ParseTestFlag(false, arraysize(argv) - 1, argv)); -} - -TEST(ParseCommandLineFlagsUsesLastDefinitionTest, - WhenFlagIsDefinedInCommandLineAndFlagFileAndThenCommandLine) { - const char* argv[] = { - "my_test", - "--test_flag=0", - GetFlagFileFlag(), - "--test_flag=3", - NULL, - }; - - EXPECT_EQ(3, ParseTestFlag(true, arraysize(argv) - 1, argv)); - EXPECT_EQ(3, ParseTestFlag(false, arraysize(argv) - 1, argv)); -} - -TEST(ParseCommandLineFlagsAndDashArgs, TwoDashArgFirst) { - const char* argv[] = { - "my_test", - "--", - "--test_flag=0", - NULL, - }; - - EXPECT_EQ(-1, ParseTestFlag(true, arraysize(argv) - 1, argv)); - EXPECT_EQ(-1, ParseTestFlag(false, arraysize(argv) - 1, argv)); -} - -TEST(ParseCommandLineFlagsAndDashArgs, TwoDashArgMiddle) { - const char* argv[] = { - "my_test", - "--test_flag=7", - "--", - "--test_flag=0", - NULL, - }; - - EXPECT_EQ(7, ParseTestFlag(true, arraysize(argv) - 1, argv)); - EXPECT_EQ(7, ParseTestFlag(false, arraysize(argv) - 1, argv)); -} - -TEST(ParseCommandLineFlagsAndDashArgs, OneDashArg) { - const char* argv[] = { - "my_test", - "-", - "--test_flag=0", - NULL, - }; - - EXPECT_EQ(0, ParseTestFlag(true, arraysize(argv) - 1, argv)); - EXPECT_EQ(0, ParseTestFlag(false, arraysize(argv) - 1, argv)); -} - -#ifdef GTEST_HAS_DEATH_TEST -TEST(ParseCommandLineFlagsUnknownFlagDeathTest, - FlagIsCompletelyUnknown) { - const char* argv[] = { - "my_test", - "--this_flag_does_not_exist", - NULL, - }; - - EXPECT_DEATH(ParseTestFlag(true, arraysize(argv) - 1, argv), - "unknown command line flag.*"); - EXPECT_DEATH(ParseTestFlag(false, arraysize(argv) - 1, argv), - "unknown command line flag.*"); -} - -TEST(ParseCommandLineFlagsUnknownFlagDeathTest, - BoolFlagIsCompletelyUnknown) { - const char* argv[] = { - "my_test", - "--nothis_flag_does_not_exist", - NULL, - }; - - EXPECT_DEATH(ParseTestFlag(true, arraysize(argv) - 1, argv), - "unknown command line flag.*"); - EXPECT_DEATH(ParseTestFlag(false, arraysize(argv) - 1, argv), - "unknown command line flag.*"); -} - -TEST(ParseCommandLineFlagsUnknownFlagDeathTest, - FlagIsNotABool) { - const char* argv[] = { - "my_test", - "--notest_string", - NULL, - }; - - EXPECT_DEATH(ParseTestFlag(true, arraysize(argv) - 1, argv), - "boolean value .* specified for .* command line flag"); - EXPECT_DEATH(ParseTestFlag(false, arraysize(argv) - 1, argv), - "boolean value .* specified for .* command line flag"); -} -#endif - -TEST(ParseCommandLineFlagsWrongFields, - DescriptionIsInvalid) { - // These must not be automatic variables, since command line flags - // aren't unregistered and gUnit uses FlagSaver to save and restore - // command line flags' values. If these are on the stack, then when - // later tests attempt to save and restore their values, the stack - // addresses of these variables will be overwritten... Stack smash! - static bool current_storage; - static bool defvalue_storage; - FlagRegisterer fr("flag_name", "bool", 0, "filename", - ¤t_storage, &defvalue_storage); - CommandLineFlagInfo fi; - EXPECT_TRUE(GetCommandLineFlagInfo("flag_name", &fi)); - EXPECT_EQ("", fi.description); - EXPECT_EQ(¤t_storage, fi.flag_ptr); -} - -static bool ValidateTestFlagIs5(const char* flagname, int32 flagval) { - if (flagval == 5) - return true; - printf("%s isn't 5!\n", flagname); - return false; -} - -static bool ValidateTestFlagIs10(const char* flagname, int32 flagval) { - return flagval == 10; -} - - -TEST(FlagsValidator, ValidFlagViaArgv) { - const char* argv[] = { - "my_test", - "--test_flag=5", - NULL, - }; - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5)); - EXPECT_EQ(5, ParseTestFlag(true, arraysize(argv) - 1, argv)); - // Undo the flag validator setting - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL)); -} - -TEST(FlagsValidator, ValidFlagViaSetDefault) { - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5)); - // SetCommandLineOptionWithMode returns the empty string on error. - EXPECT_NE("", SetCommandLineOptionWithMode("test_flag", "5", - SET_FLAG_IF_DEFAULT)); - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL)); -} - -TEST(FlagsValidator, ValidFlagViaSetValue) { - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5)); - FLAGS_test_flag = 100; // doesn't trigger the validator - // SetCommandLineOptionWithMode returns the empty string on error. - EXPECT_NE("", SetCommandLineOptionWithMode("test_flag", "5", - SET_FLAGS_VALUE)); - EXPECT_NE("", SetCommandLineOptionWithMode("test_flag", "5", - SET_FLAGS_DEFAULT)); - EXPECT_NE("", SetCommandLineOption("test_flag", "5")); - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL)); -} - -#ifdef GTEST_HAS_DEATH_TEST -TEST(FlagsValidatorDeathTest, InvalidFlagViaArgv) { - const char* argv[] = { - "my_test", - "--test_flag=50", - NULL, - }; - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5)); - EXPECT_DEATH(ParseTestFlag(true, arraysize(argv) - 1, argv), - "ERROR: failed validation of new value '50' for flag 'test_flag'"); - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL)); -} -#endif - -TEST(FlagsValidator, InvalidFlagViaSetDefault) { - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5)); - // SetCommandLineOptionWithMode returns the empty string on error. - EXPECT_EQ("", SetCommandLineOptionWithMode("test_flag", "50", - SET_FLAG_IF_DEFAULT)); - EXPECT_EQ(-1, FLAGS_test_flag); // the setting-to-50 should have failed - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL)); -} - -TEST(FlagsValidator, InvalidFlagViaSetValue) { - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5)); - FLAGS_test_flag = 100; // doesn't trigger the validator - // SetCommandLineOptionWithMode returns the empty string on error. - EXPECT_EQ("", SetCommandLineOptionWithMode("test_flag", "50", - SET_FLAGS_VALUE)); - EXPECT_EQ("", SetCommandLineOptionWithMode("test_flag", "50", - SET_FLAGS_DEFAULT)); - EXPECT_EQ("", SetCommandLineOption("test_flag", "50")); - EXPECT_EQ(100, FLAGS_test_flag); // the setting-to-50 should have failed - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL)); -} - -#ifdef GTEST_HAS_DEATH_TEST -TEST(FlagsValidatorDeathTest, InvalidFlagNeverSet) { - // If a flag keeps its default value, and that default value is - // invalid, we should die at argv-parse time. - const char* argv[] = { - "my_test", - NULL, - }; - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5)); - EXPECT_DEATH(ParseTestFlag(true, arraysize(argv) - 1, argv), - "ERROR: --test_flag must be set on the commandline"); -} -#endif - -TEST(FlagsValidator, InvalidFlagPtr) { - int32 dummy; - EXPECT_FALSE(RegisterFlagValidator(NULL, &ValidateTestFlagIs5)); - EXPECT_FALSE(RegisterFlagValidator(&dummy, &ValidateTestFlagIs5)); -} - -TEST(FlagsValidator, RegisterValidatorTwice) { - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5)); - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5)); - EXPECT_FALSE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs10)); - EXPECT_FALSE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs10)); - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5)); - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL)); - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs10)); - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL)); -} - -TEST(FlagsValidator, CommandLineFlagInfo) { - CommandLineFlagInfo info; - info = GetCommandLineFlagInfoOrDie("test_flag"); - EXPECT_FALSE(info.has_validator_fn); - - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5)); - info = GetCommandLineFlagInfoOrDie("test_flag"); - EXPECT_TRUE(info.has_validator_fn); - - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL)); - info = GetCommandLineFlagInfoOrDie("test_flag"); - EXPECT_FALSE(info.has_validator_fn); -} - -TEST(FlagsValidator, FlagSaver) { - { - FlagSaver fs; - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5)); - EXPECT_EQ("", SetCommandLineOption("test_flag", "50")); // fails validation - } - EXPECT_NE("", SetCommandLineOption("test_flag", "50")); // validator is gone - - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5)); - { - FlagSaver fs; - EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL)); - EXPECT_NE("", SetCommandLineOption("test_flag", "50")); // no validator - } - EXPECT_EQ("", SetCommandLineOption("test_flag", "50")); // validator is back -} - - -} // unnamed namespace - -int main(int argc, char **argv) { - - // Run unit tests only if called without arguments, otherwise this program - // is used by an "external" usage test - const bool run_tests = (argc == 1); - - // We need to call SetArgv before parsing flags, so our "test" argv will - // win out over this executable's real argv. That makes running this - // test with a real --help flag kinda annoying, unfortunately. - const char* test_argv[] = { "/test/argv/for/gflags_unittest", - "argv 2", "3rd argv", "argv #4" }; - SetArgv(arraysize(test_argv), test_argv); - - // The first arg is the usage message, also important for testing. - string usage_message = (string(GetArgv0()) + - ": <useless flag> [...]\nDoes something useless.\n"); - - // We test setting tryfromenv manually, and making sure - // ParseCommandLineFlags still evaluates it. - FLAGS_tryfromenv = "test_tryfromenv"; - setenv("FLAGS_test_tryfromenv", "pre-set", 1); - - // Modify flag values from declared default value in two ways. - // The recommended way: - SetCommandLineOptionWithMode("changed_bool1", "true", SET_FLAGS_DEFAULT); - - // The non-recommended way: - FLAGS_changed_bool2 = true; - - SetUsageMessage(usage_message.c_str()); - SetVersionString("test_version"); - ParseCommandLineFlags(&argc, &argv, true); - MakeTmpdir(&FLAGS_test_tmpdir); - - int exit_status = 0; - if (run_tests) { - fprintf(stdout, "Running the unit tests now...\n\n"); fflush(stdout); - exit_status = RUN_ALL_TESTS(); - } else fprintf(stderr, "\n\nPASS\n"); - ShutDownCommandLineFlags(); - return exit_status; -} - -} // GFLAGS_NAMESPACE - -int main(int argc, char** argv) { - return GFLAGS_NAMESPACE::main(argc, argv); -} -
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/84d1e166/third_party/src/tmb/third_party/gflags/test/gflags_unittest_flagfile ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/test/gflags_unittest_flagfile b/third_party/src/tmb/third_party/gflags/test/gflags_unittest_flagfile deleted file mode 100644 index f4fa0c4..0000000 --- a/third_party/src/tmb/third_party/gflags/test/gflags_unittest_flagfile +++ /dev/null @@ -1,2 +0,0 @@ ---test_flag=1 ---test_flag=2 http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/84d1e166/third_party/src/tmb/third_party/gflags/test/nc/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/test/nc/CMakeLists.txt b/third_party/src/tmb/third_party/gflags/test/nc/CMakeLists.txt deleted file mode 100644 index 823fc67..0000000 --- a/third_party/src/tmb/third_party/gflags/test/nc/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -## gflags negative compilation tests - -cmake_minimum_required (VERSION 2.8) - -if (NOT TEST_NAME) - message (FATAL_ERROR "Missing TEST_NAME CMake flag") -endif () -string (TOUPPER ${TEST_NAME} TEST_NAME_UPPER) - -project (gflags_nc_${TEST_NAME}) - -find_package (gflags REQUIRED) -include_directories (${gflags_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/..") -link_libraries (gflags_nothreads) -add_definitions (-DTEST_${TEST_NAME_UPPER}) -add_executable (gflags_nc_${TEST_NAME} gflags_nc.cc) http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/84d1e166/third_party/src/tmb/third_party/gflags/test/nc/gflags_nc.cc ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gflags/test/nc/gflags_nc.cc b/third_party/src/tmb/third_party/gflags/test/nc/gflags_nc.cc deleted file mode 100644 index 23398f2..0000000 --- a/third_party/src/tmb/third_party/gflags/test/nc/gflags_nc.cc +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2009, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// --- -// -// A negative comiple test for gflags. - -#include <gflags/gflags.h> - -#if defined(TEST_SWAPPED_ARGS) - -DEFINE_bool(some_bool_flag, - "the default value should go here, not the description", - false); - - -#elif defined(TEST_INT_INSTEAD_OF_BOOL) - -DEFINE_bool(some_bool_flag_2, - 0, - "should have been an int32 flag but mistakenly used bool instead"); - -#elif defined(TEST_BOOL_IN_QUOTES) - - -DEFINE_bool(some_bool_flag_3, - "false", - "false in in quotes, which is wrong"); - -#elif defined(TEST_SANITY) - -DEFINE_bool(some_bool_flag_4, - true, - "this is the correct usage of DEFINE_bool"); - -#elif defined(TEST_DEFINE_STRING_WITH_0) - -DEFINE_string(some_string_flag, - 0, - "Trying to construct a string by passing 0 would cause a crash."); - -#endif - -int main(int, char **) -{ - return 0; -} http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/84d1e166/third_party/src/tmb/third_party/gtest/CHANGES ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gtest/CHANGES b/third_party/src/tmb/third_party/gtest/CHANGES deleted file mode 100644 index 0552132..0000000 --- a/third_party/src/tmb/third_party/gtest/CHANGES +++ /dev/null @@ -1,157 +0,0 @@ -Changes for 1.7.0: - -* New feature: death tests are supported on OpenBSD and in iOS - simulator now. -* New feature: Google Test now implements a protocol to allow - a test runner to detect that a test program has exited - prematurely and report it as a failure (before it would be - falsely reported as a success if the exit code is 0). -* New feature: Test::RecordProperty() can now be used outside of the - lifespan of a test method, in which case it will be attributed to - the current test case or the test program in the XML report. -* New feature (potentially breaking): --gtest_list_tests now prints - the type parameters and value parameters for each test. -* Improvement: char pointers and char arrays are now escaped properly - in failure messages. -* Improvement: failure summary in XML reports now includes file and - line information. -* Improvement: the <testsuites> XML element now has a timestamp attribute. -* Improvement: When --gtest_filter is specified, XML report now doesn't - contain information about tests that are filtered out. -* Fixed the bug where long --gtest_filter flag values are truncated in - death tests. -* Potentially breaking change: RUN_ALL_TESTS() is now implemented as a - function instead of a macro in order to work better with Clang. -* Compatibility fixes with C++ 11 and various platforms. -* Bug/warning fixes. - -Changes for 1.6.0: - -* New feature: ADD_FAILURE_AT() for reporting a test failure at the - given source location -- useful for writing testing utilities. -* New feature: the universal value printer is moved from Google Mock - to Google Test. -* New feature: type parameters and value parameters are reported in - the XML report now. -* A gtest_disable_pthreads CMake option. -* Colored output works in GNU Screen sessions now. -* Parameters of value-parameterized tests are now printed in the - textual output. -* Failures from ad hoc test assertions run before RUN_ALL_TESTS() are - now correctly reported. -* Arguments of ASSERT_XY and EXPECT_XY no longer need to support << to - ostream. -* More complete handling of exceptions. -* GTEST_ASSERT_XY can be used instead of ASSERT_XY in case the latter - name is already used by another library. -* --gtest_catch_exceptions is now true by default, allowing a test - program to continue after an exception is thrown. -* Value-parameterized test fixtures can now derive from Test and - WithParamInterface<T> separately, easing conversion of legacy tests. -* Death test messages are clearly marked to make them more - distinguishable from other messages. -* Compatibility fixes for Android, Google Native Client, MinGW, HP UX, - PowerPC, Lucid autotools, libCStd, Sun C++, Borland C++ Builder (Code Gear), - IBM XL C++ (Visual Age C++), and C++0x. -* Bug fixes and implementation clean-ups. -* Potentially incompatible changes: disables the harmful 'make install' - command in autotools. - -Changes for 1.5.0: - - * New feature: assertions can be safely called in multiple threads - where the pthreads library is available. - * New feature: predicates used inside EXPECT_TRUE() and friends - can now generate custom failure messages. - * New feature: Google Test can now be compiled as a DLL. - * New feature: fused source files are included. - * New feature: prints help when encountering unrecognized Google Test flags. - * Experimental feature: CMake build script (requires CMake 2.6.4+). - * Experimental feature: the Pump script for meta programming. - * double values streamed to an assertion are printed with enough precision - to differentiate any two different values. - * Google Test now works on Solaris and AIX. - * Build and test script improvements. - * Bug fixes and implementation clean-ups. - - Potentially breaking changes: - - * Stopped supporting VC++ 7.1 with exceptions disabled. - * Dropped support for 'make install'. - -Changes for 1.4.0: - - * New feature: the event listener API - * New feature: test shuffling - * New feature: the XML report format is closer to junitreport and can - be parsed by Hudson now. - * New feature: when a test runs under Visual Studio, its failures are - integrated in the IDE. - * New feature: /MD(d) versions of VC++ projects. - * New feature: elapsed time for the tests is printed by default. - * New feature: comes with a TR1 tuple implementation such that Boost - is no longer needed for Combine(). - * New feature: EXPECT_DEATH_IF_SUPPORTED macro and friends. - * New feature: the Xcode project can now produce static gtest - libraries in addition to a framework. - * Compatibility fixes for Solaris, Cygwin, minGW, Windows Mobile, - Symbian, gcc, and C++Builder. - * Bug fixes and implementation clean-ups. - -Changes for 1.3.0: - - * New feature: death tests on Windows, Cygwin, and Mac. - * New feature: ability to use Google Test assertions in other testing - frameworks. - * New feature: ability to run disabled test via - --gtest_also_run_disabled_tests. - * New feature: the --help flag for printing the usage. - * New feature: access to Google Test flag values in user code. - * New feature: a script that packs Google Test into one .h and one - .cc file for easy deployment. - * New feature: support for distributing test functions to multiple - machines (requires support from the test runner). - * Bug fixes and implementation clean-ups. - -Changes for 1.2.1: - - * Compatibility fixes for Linux IA-64 and IBM z/OS. - * Added support for using Boost and other TR1 implementations. - * Changes to the build scripts to support upcoming release of Google C++ - Mocking Framework. - * Added Makefile to the distribution package. - * Improved build instructions in README. - -Changes for 1.2.0: - - * New feature: value-parameterized tests. - * New feature: the ASSERT/EXPECT_(NON)FATAL_FAILURE(_ON_ALL_THREADS) - macros. - * Changed the XML report format to match JUnit/Ant's. - * Added tests to the Xcode project. - * Added scons/SConscript for building with SCons. - * Added src/gtest-all.cc for building Google Test from a single file. - * Fixed compatibility with Solaris and z/OS. - * Enabled running Python tests on systems with python 2.3 installed, - e.g. Mac OS X 10.4. - * Bug fixes. - -Changes for 1.1.0: - - * New feature: type-parameterized tests. - * New feature: exception assertions. - * New feature: printing elapsed time of tests. - * Improved the robustness of death tests. - * Added an Xcode project and samples. - * Adjusted the output format on Windows to be understandable by Visual Studio. - * Minor bug fixes. - -Changes for 1.0.1: - - * Added project files for Visual Studio 7.1. - * Fixed issues with compiling on Mac OS X. - * Fixed issues with compiling on Cygwin. - -Changes for 1.0.0: - - * Initial Open Source release of Google Test http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/84d1e166/third_party/src/tmb/third_party/gtest/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gtest/CMakeLists.txt b/third_party/src/tmb/third_party/gtest/CMakeLists.txt deleted file mode 100644 index 57470c8..0000000 --- a/third_party/src/tmb/third_party/gtest/CMakeLists.txt +++ /dev/null @@ -1,252 +0,0 @@ -######################################################################## -# CMake build script for Google Test. -# -# To run the tests for Google Test itself on Linux, use 'make test' or -# ctest. You can select which tests to run using 'ctest -R regex'. -# For more options, run 'ctest --help'. - -# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to -# make it prominent in the GUI. -option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF) - -# When other libraries are using a shared version of runtime libraries, -# Google Test also has to use one. -option( - gtest_force_shared_crt - "Use shared (DLL) run-time lib even when Google Test is built as static lib." - OFF) - -option(gtest_build_tests "Build all of gtest's own tests." OFF) - -option(gtest_build_samples "Build gtest's sample programs." OFF) - -option(gtest_disable_pthreads "Disable uses of pthreads in gtest." OFF) - -# Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build(). -include(cmake/hermetic_build.cmake OPTIONAL) - -if (COMMAND pre_project_set_up_hermetic_build) - pre_project_set_up_hermetic_build() -endif() - -######################################################################## -# -# Project-wide settings - -# Name of the project. -# -# CMake files in this project can refer to the root source directory -# as ${gtest_SOURCE_DIR} and to the root binary directory as -# ${gtest_BINARY_DIR}. -# Language "C" is required for find_package(Threads). -project(gtest CXX C) -cmake_minimum_required(VERSION 2.6.2) - -if (COMMAND set_up_hermetic_build) - set_up_hermetic_build() -endif() - -# Define helper functions and macros used by Google Test. -include(cmake/internal_utils.cmake) - -config_compiler_and_linker() # Defined in internal_utils.cmake. - -# Where Google Test's .h files can be found. -include_directories( - ${gtest_SOURCE_DIR}/include - ${gtest_SOURCE_DIR}) - -# Where Google Test's libraries can be found. -link_directories(${gtest_BINARY_DIR}/src) - -######################################################################## -# -# Defines the gtest & gtest_main libraries. User tests should link -# with one of them. - -# Google Test libraries. We build them using more strict warnings than what -# are used for other targets, to ensure that gtest can be compiled by a user -# aggressive about warnings. -cxx_library(gtest "${cxx_strict}" src/gtest-all.cc) -cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc) -target_link_libraries(gtest_main gtest) - -######################################################################## -# -# Samples on how to link user tests with gtest or gtest_main. -# -# They are not built by default. To build them, set the -# gtest_build_samples option to ON. You can do it by running ccmake -# or specifying the -Dgtest_build_samples=ON flag when running cmake. - -if (gtest_build_samples) - cxx_executable(sample1_unittest samples gtest_main samples/sample1.cc) - cxx_executable(sample2_unittest samples gtest_main samples/sample2.cc) - cxx_executable(sample3_unittest samples gtest_main) - cxx_executable(sample4_unittest samples gtest_main samples/sample4.cc) - cxx_executable(sample5_unittest samples gtest_main samples/sample1.cc) - cxx_executable(sample6_unittest samples gtest_main) - cxx_executable(sample7_unittest samples gtest_main) - cxx_executable(sample8_unittest samples gtest_main) - cxx_executable(sample9_unittest samples gtest) - cxx_executable(sample10_unittest samples gtest) -endif() - -######################################################################## -# -# Google Test's own tests. -# -# You can skip this section if you aren't interested in testing -# Google Test itself. -# -# The tests are not built by default. To build them, set the -# gtest_build_tests option to ON. You can do it by running ccmake -# or specifying the -Dgtest_build_tests=ON flag when running cmake. - -if (gtest_build_tests) - # This must be set in the root directory for the tests to be run by - # 'make test' or ctest. - enable_testing() - - ############################################################ - # C++ tests built with standard compiler flags. - - cxx_test(gtest-death-test_test gtest_main) - cxx_test(gtest_environment_test gtest) - cxx_test(gtest-filepath_test gtest_main) - cxx_test(gtest-linked_ptr_test gtest_main) - cxx_test(gtest-listener_test gtest_main) - cxx_test(gtest_main_unittest gtest_main) - cxx_test(gtest-message_test gtest_main) - cxx_test(gtest_no_test_unittest gtest) - cxx_test(gtest-options_test gtest_main) - cxx_test(gtest-param-test_test gtest - test/gtest-param-test2_test.cc) - cxx_test(gtest-port_test gtest_main) - cxx_test(gtest_pred_impl_unittest gtest_main) - cxx_test(gtest_premature_exit_test gtest - test/gtest_premature_exit_test.cc) - cxx_test(gtest-printers_test gtest_main) - cxx_test(gtest_prod_test gtest_main - test/production.cc) - cxx_test(gtest_repeat_test gtest) - cxx_test(gtest_sole_header_test gtest_main) - cxx_test(gtest_stress_test gtest) - cxx_test(gtest-test-part_test gtest_main) - cxx_test(gtest_throw_on_failure_ex_test gtest) - cxx_test(gtest-typed-test_test gtest_main - test/gtest-typed-test2_test.cc) - cxx_test(gtest_unittest gtest_main) - cxx_test(gtest-unittest-api_test gtest) - - ############################################################ - # C++ tests built with non-standard compiler flags. - - # MSVC 7.1 does not support STL with exceptions disabled. - if (NOT MSVC OR MSVC_VERSION GREATER 1310) - cxx_library(gtest_no_exception "${cxx_no_exception}" - src/gtest-all.cc) - cxx_library(gtest_main_no_exception "${cxx_no_exception}" - src/gtest-all.cc src/gtest_main.cc) - endif() - cxx_library(gtest_main_no_rtti "${cxx_no_rtti}" - src/gtest-all.cc src/gtest_main.cc) - - cxx_test_with_flags(gtest-death-test_ex_nocatch_test - "${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=0" - gtest test/gtest-death-test_ex_test.cc) - cxx_test_with_flags(gtest-death-test_ex_catch_test - "${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=1" - gtest test/gtest-death-test_ex_test.cc) - - cxx_test_with_flags(gtest_no_rtti_unittest "${cxx_no_rtti}" - gtest_main_no_rtti test/gtest_unittest.cc) - - cxx_shared_library(gtest_dll "${cxx_default}" - src/gtest-all.cc src/gtest_main.cc) - - cxx_executable_with_flags(gtest_dll_test_ "${cxx_default}" - gtest_dll test/gtest_all_test.cc) - set_target_properties(gtest_dll_test_ - PROPERTIES - COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1") - - if (NOT MSVC OR NOT MSVC_VERSION EQUAL 1600) - # The C++ Standard specifies tuple_element<int, class>. - # Yet MSVC 10's <utility> declares tuple_element<size_t, class>. - # That declaration conflicts with our own standard-conforming - # tuple implementation. Therefore using our own tuple with - # MSVC 10 doesn't compile. - cxx_library(gtest_main_use_own_tuple "${cxx_use_own_tuple}" - src/gtest-all.cc src/gtest_main.cc) - - cxx_test_with_flags(gtest-tuple_test "${cxx_use_own_tuple}" - gtest_main_use_own_tuple test/gtest-tuple_test.cc) - - cxx_test_with_flags(gtest_use_own_tuple_test "${cxx_use_own_tuple}" - gtest_main_use_own_tuple - test/gtest-param-test_test.cc test/gtest-param-test2_test.cc) - endif() - - ############################################################ - # Python tests. - - cxx_executable(gtest_break_on_failure_unittest_ test gtest) - py_test(gtest_break_on_failure_unittest) - - # MSVC 7.1 does not support STL with exceptions disabled. - if (NOT MSVC OR MSVC_VERSION GREATER 1310) - cxx_executable_with_flags( - gtest_catch_exceptions_no_ex_test_ - "${cxx_no_exception}" - gtest_main_no_exception - test/gtest_catch_exceptions_test_.cc) - endif() - - cxx_executable_with_flags( - gtest_catch_exceptions_ex_test_ - "${cxx_exception}" - gtest_main - test/gtest_catch_exceptions_test_.cc) - py_test(gtest_catch_exceptions_test) - - cxx_executable(gtest_color_test_ test gtest) - py_test(gtest_color_test) - - cxx_executable(gtest_env_var_test_ test gtest) - py_test(gtest_env_var_test) - - cxx_executable(gtest_filter_unittest_ test gtest) - py_test(gtest_filter_unittest) - - cxx_executable(gtest_help_test_ test gtest_main) - py_test(gtest_help_test) - - cxx_executable(gtest_list_tests_unittest_ test gtest) - py_test(gtest_list_tests_unittest) - - cxx_executable(gtest_output_test_ test gtest) - py_test(gtest_output_test) - - cxx_executable(gtest_shuffle_test_ test gtest) - py_test(gtest_shuffle_test) - - # MSVC 7.1 does not support STL with exceptions disabled. - if (NOT MSVC OR MSVC_VERSION GREATER 1310) - cxx_executable(gtest_throw_on_failure_test_ test gtest_no_exception) - set_target_properties(gtest_throw_on_failure_test_ - PROPERTIES - COMPILE_FLAGS "${cxx_no_exception}") - py_test(gtest_throw_on_failure_test) - endif() - - cxx_executable(gtest_uninitialized_test_ test gtest) - py_test(gtest_uninitialized_test) - - cxx_executable(gtest_xml_outfile1_test_ test gtest_main) - cxx_executable(gtest_xml_outfile2_test_ test gtest_main) - py_test(gtest_xml_outfiles_test) - - cxx_executable(gtest_xml_output_unittest_ test gtest) - py_test(gtest_xml_output_unittest) -endif() http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/84d1e166/third_party/src/tmb/third_party/gtest/CONTRIBUTORS ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gtest/CONTRIBUTORS b/third_party/src/tmb/third_party/gtest/CONTRIBUTORS deleted file mode 100644 index feae2fc..0000000 --- a/third_party/src/tmb/third_party/gtest/CONTRIBUTORS +++ /dev/null @@ -1,37 +0,0 @@ -# This file contains a list of people who've made non-trivial -# contribution to the Google C++ Testing Framework project. People -# who commit code to the project are encouraged to add their names -# here. Please keep the list sorted by first names. - -Ajay Joshi <j...@google.com> -Balázs Dán <balazs....@gmail.com> -Bharat Mediratta <bha...@menalto.com> -Chandler Carruth <chandl...@google.com> -Chris Prince <cpri...@google.com> -Chris Taylor <tayl...@google.com> -Dan Egnor <eg...@google.com> -Eric Roman <ero...@chromium.org> -Hady Zalek <hady.za...@gmail.com> -Jeffrey Yasskin <jyass...@google.com> -Jói Sigurðsson <j...@google.com> -Keir Mierle <mie...@gmail.com> -Keith Ray <keith....@gmail.com> -Kenton Varda <ken...@google.com> -Manuel Klimek <kli...@google.com> -Markus Heule <markus.he...@gmail.com> -Mika Raento <mi...@iki.fi> -Miklós Fazekas <mfaze...@szemafor.com> -Pasi Valminen <pasi.valmi...@gmail.com> -Patrick Hanna <pha...@google.com> -Patrick Riley <p...@google.com> -Peter Kaminski <pio...@google.com> -Preston Jackson <preston.a.jack...@gmail.com> -Rainer Klaffenboeck <rainer.klaffenbo...@dynatrace.com> -Russ Cox <r...@google.com> -Russ Rufer <r...@pentad.com> -Sean Mcafee <eef...@gmail.com> -Sigurður Ãsgeirsson <si...@google.com> -Tracy Bialik <tr...@pentad.com> -Vadim Berman <vad...@google.com> -Vlad Losev <vl...@google.com> -Zhanyong Wan <w...@google.com> http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/84d1e166/third_party/src/tmb/third_party/gtest/LICENSE ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gtest/LICENSE b/third_party/src/tmb/third_party/gtest/LICENSE deleted file mode 100644 index 1941a11..0000000 --- a/third_party/src/tmb/third_party/gtest/LICENSE +++ /dev/null @@ -1,28 +0,0 @@ -Copyright 2008, Google Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/84d1e166/third_party/src/tmb/third_party/gtest/Makefile.am ---------------------------------------------------------------------- diff --git a/third_party/src/tmb/third_party/gtest/Makefile.am b/third_party/src/tmb/third_party/gtest/Makefile.am deleted file mode 100644 index 9c96b42..0000000 --- a/third_party/src/tmb/third_party/gtest/Makefile.am +++ /dev/null @@ -1,306 +0,0 @@ -# Automake file - -ACLOCAL_AMFLAGS = -I m4 - -# Nonstandard package files for distribution -EXTRA_DIST = \ - CHANGES \ - CONTRIBUTORS \ - LICENSE \ - include/gtest/gtest-param-test.h.pump \ - include/gtest/internal/gtest-param-util-generated.h.pump \ - include/gtest/internal/gtest-tuple.h.pump \ - include/gtest/internal/gtest-type-util.h.pump \ - make/Makefile \ - scripts/fuse_gtest_files.py \ - scripts/gen_gtest_pred_impl.py \ - scripts/pump.py \ - scripts/test/Makefile - -# gtest source files that we don't compile directly. They are -# #included by gtest-all.cc. -GTEST_SRC = \ - src/gtest-death-test.cc \ - src/gtest-filepath.cc \ - src/gtest-internal-inl.h \ - src/gtest-port.cc \ - src/gtest-printers.cc \ - src/gtest-test-part.cc \ - src/gtest-typed-test.cc \ - src/gtest.cc - -EXTRA_DIST += $(GTEST_SRC) - -# Sample files that we don't compile. -EXTRA_DIST += \ - samples/prime_tables.h \ - samples/sample2_unittest.cc \ - samples/sample3_unittest.cc \ - samples/sample4_unittest.cc \ - samples/sample5_unittest.cc \ - samples/sample6_unittest.cc \ - samples/sample7_unittest.cc \ - samples/sample8_unittest.cc \ - samples/sample9_unittest.cc - -# C++ test files that we don't compile directly. -EXTRA_DIST += \ - test/gtest-death-test_ex_test.cc \ - test/gtest-death-test_test.cc \ - test/gtest-filepath_test.cc \ - test/gtest-linked_ptr_test.cc \ - test/gtest-listener_test.cc \ - test/gtest-message_test.cc \ - test/gtest-options_test.cc \ - test/gtest-param-test2_test.cc \ - test/gtest-param-test2_test.cc \ - test/gtest-param-test_test.cc \ - test/gtest-param-test_test.cc \ - test/gtest-param-test_test.h \ - test/gtest-port_test.cc \ - test/gtest_premature_exit_test.cc \ - test/gtest-printers_test.cc \ - test/gtest-test-part_test.cc \ - test/gtest-tuple_test.cc \ - test/gtest-typed-test2_test.cc \ - test/gtest-typed-test_test.cc \ - test/gtest-typed-test_test.h \ - test/gtest-unittest-api_test.cc \ - test/gtest_break_on_failure_unittest_.cc \ - test/gtest_catch_exceptions_test_.cc \ - test/gtest_color_test_.cc \ - test/gtest_env_var_test_.cc \ - test/gtest_environment_test.cc \ - test/gtest_filter_unittest_.cc \ - test/gtest_help_test_.cc \ - test/gtest_list_tests_unittest_.cc \ - test/gtest_main_unittest.cc \ - test/gtest_no_test_unittest.cc \ - test/gtest_output_test_.cc \ - test/gtest_pred_impl_unittest.cc \ - test/gtest_prod_test.cc \ - test/gtest_repeat_test.cc \ - test/gtest_shuffle_test_.cc \ - test/gtest_sole_header_test.cc \ - test/gtest_stress_test.cc \ - test/gtest_throw_on_failure_ex_test.cc \ - test/gtest_throw_on_failure_test_.cc \ - test/gtest_uninitialized_test_.cc \ - test/gtest_unittest.cc \ - test/gtest_unittest.cc \ - test/gtest_xml_outfile1_test_.cc \ - test/gtest_xml_outfile2_test_.cc \ - test/gtest_xml_output_unittest_.cc \ - test/production.cc \ - test/production.h - -# Python tests that we don't run. -EXTRA_DIST += \ - test/gtest_break_on_failure_unittest.py \ - test/gtest_catch_exceptions_test.py \ - test/gtest_color_test.py \ - test/gtest_env_var_test.py \ - test/gtest_filter_unittest.py \ - test/gtest_help_test.py \ - test/gtest_list_tests_unittest.py \ - test/gtest_output_test.py \ - test/gtest_output_test_golden_lin.txt \ - test/gtest_shuffle_test.py \ - test/gtest_test_utils.py \ - test/gtest_throw_on_failure_test.py \ - test/gtest_uninitialized_test.py \ - test/gtest_xml_outfiles_test.py \ - test/gtest_xml_output_unittest.py \ - test/gtest_xml_test_utils.py - -# CMake script -EXTRA_DIST += \ - CMakeLists.txt \ - cmake/internal_utils.cmake - -# MSVC project files -EXTRA_DIST += \ - msvc/gtest-md.sln \ - msvc/gtest-md.vcproj \ - msvc/gtest.sln \ - msvc/gtest.vcproj \ - msvc/gtest_main-md.vcproj \ - msvc/gtest_main.vcproj \ - msvc/gtest_prod_test-md.vcproj \ - msvc/gtest_prod_test.vcproj \ - msvc/gtest_unittest-md.vcproj \ - msvc/gtest_unittest.vcproj - -# xcode project files -EXTRA_DIST += \ - xcode/Config/DebugProject.xcconfig \ - xcode/Config/FrameworkTarget.xcconfig \ - xcode/Config/General.xcconfig \ - xcode/Config/ReleaseProject.xcconfig \ - xcode/Config/StaticLibraryTarget.xcconfig \ - xcode/Config/TestTarget.xcconfig \ - xcode/Resources/Info.plist \ - xcode/Scripts/runtests.sh \ - xcode/Scripts/versiongenerate.py \ - xcode/gtest.xcodeproj/project.pbxproj - -# xcode sample files -EXTRA_DIST += \ - xcode/Samples/FrameworkSample/Info.plist \ - xcode/Samples/FrameworkSample/WidgetFramework.xcodeproj/project.pbxproj \ - xcode/Samples/FrameworkSample/runtests.sh \ - xcode/Samples/FrameworkSample/widget.cc \ - xcode/Samples/FrameworkSample/widget.h \ - xcode/Samples/FrameworkSample/widget_test.cc - -# C++Builder project files -EXTRA_DIST += \ - codegear/gtest.cbproj \ - codegear/gtest.groupproj \ - codegear/gtest_all.cc \ - codegear/gtest_link.cc \ - codegear/gtest_main.cbproj \ - codegear/gtest_unittest.cbproj - -# Distribute and install M4 macro -m4datadir = $(datadir)/aclocal -m4data_DATA = m4/gtest.m4 -EXTRA_DIST += $(m4data_DATA) - -# We define the global AM_CPPFLAGS as everything we compile includes from these -# directories. -AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/include - -# Modifies compiler and linker flags for pthreads compatibility. -if HAVE_PTHREADS - AM_CXXFLAGS = @PTHREAD_CFLAGS@ -DGTEST_HAS_PTHREAD=1 - AM_LIBS = @PTHREAD_LIBS@ -else - AM_CXXFLAGS = -DGTEST_HAS_PTHREAD=0 -endif - -# Build rules for libraries. -lib_LTLIBRARIES = lib/libgtest.la lib/libgtest_main.la - -lib_libgtest_la_SOURCES = src/gtest-all.cc - -pkginclude_HEADERS = \ - include/gtest/gtest-death-test.h \ - include/gtest/gtest-message.h \ - include/gtest/gtest-param-test.h \ - include/gtest/gtest-printers.h \ - include/gtest/gtest-spi.h \ - include/gtest/gtest-test-part.h \ - include/gtest/gtest-typed-test.h \ - include/gtest/gtest.h \ - include/gtest/gtest_pred_impl.h \ - include/gtest/gtest_prod.h - -pkginclude_internaldir = $(pkgincludedir)/internal -pkginclude_internal_HEADERS = \ - include/gtest/internal/gtest-death-test-internal.h \ - include/gtest/internal/gtest-filepath.h \ - include/gtest/internal/gtest-internal.h \ - include/gtest/internal/gtest-linked_ptr.h \ - include/gtest/internal/gtest-param-util-generated.h \ - include/gtest/internal/gtest-param-util.h \ - include/gtest/internal/gtest-port.h \ - include/gtest/internal/gtest-string.h \ - include/gtest/internal/gtest-tuple.h \ - include/gtest/internal/gtest-type-util.h - -lib_libgtest_main_la_SOURCES = src/gtest_main.cc -lib_libgtest_main_la_LIBADD = lib/libgtest.la - -# Bulid rules for samples and tests. Automake's naming for some of -# these variables isn't terribly obvious, so this is a brief -# reference: -# -# TESTS -- Programs run automatically by "make check" -# check_PROGRAMS -- Programs built by "make check" but not necessarily run - -noinst_LTLIBRARIES = samples/libsamples.la - -samples_libsamples_la_SOURCES = \ - samples/sample1.cc \ - samples/sample1.h \ - samples/sample2.cc \ - samples/sample2.h \ - samples/sample3-inl.h \ - samples/sample4.cc \ - samples/sample4.h - -TESTS= -TESTS_ENVIRONMENT = GTEST_SOURCE_DIR="$(srcdir)/test" \ - GTEST_BUILD_DIR="$(top_builddir)/test" -check_PROGRAMS= - -# A simple sample on using gtest. -TESTS += samples/sample1_unittest -check_PROGRAMS += samples/sample1_unittest -samples_sample1_unittest_SOURCES = samples/sample1_unittest.cc -samples_sample1_unittest_LDADD = lib/libgtest_main.la \ - lib/libgtest.la \ - samples/libsamples.la - -# Another sample. It also verifies that libgtest works. -TESTS += samples/sample10_unittest -check_PROGRAMS += samples/sample10_unittest -samples_sample10_unittest_SOURCES = samples/sample10_unittest.cc -samples_sample10_unittest_LDADD = lib/libgtest.la - -# This tests most constructs of gtest and verifies that libgtest_main -# and libgtest work. -TESTS += test/gtest_all_test -check_PROGRAMS += test/gtest_all_test -test_gtest_all_test_SOURCES = test/gtest_all_test.cc -test_gtest_all_test_LDADD = lib/libgtest_main.la \ - lib/libgtest.la - -# Tests that fused gtest files compile and work. -FUSED_GTEST_SRC = \ - fused-src/gtest/gtest-all.cc \ - fused-src/gtest/gtest.h \ - fused-src/gtest/gtest_main.cc - -if HAVE_PYTHON -TESTS += test/fused_gtest_test -check_PROGRAMS += test/fused_gtest_test -test_fused_gtest_test_SOURCES = $(FUSED_GTEST_SRC) \ - samples/sample1.cc samples/sample1_unittest.cc -test_fused_gtest_test_CPPFLAGS = -I"$(srcdir)/fused-src" - -# Build rules for putting fused Google Test files into the distribution -# package. The user can also create those files by manually running -# scripts/fuse_gtest_files.py. -$(test_fused_gtest_test_SOURCES): fused-gtest - -fused-gtest: $(pkginclude_HEADERS) $(pkginclude_internal_HEADERS) \ - $(GTEST_SRC) src/gtest-all.cc src/gtest_main.cc \ - scripts/fuse_gtest_files.py - mkdir -p "$(srcdir)/fused-src" - chmod -R u+w "$(srcdir)/fused-src" - rm -f "$(srcdir)/fused-src/gtest/gtest-all.cc" - rm -f "$(srcdir)/fused-src/gtest/gtest.h" - "$(srcdir)/scripts/fuse_gtest_files.py" "$(srcdir)/fused-src" - cp -f "$(srcdir)/src/gtest_main.cc" "$(srcdir)/fused-src/gtest/" - -maintainer-clean-local: - rm -rf "$(srcdir)/fused-src" -endif - -# Death tests may produce core dumps in the build directory. In case -# this happens, clean them to keep distcleancheck happy. -CLEANFILES = core - -# Disables 'make install' as installing a compiled version of Google -# Test can lead to undefined behavior due to violation of the -# One-Definition Rule. - -install-exec-local: - echo "'make install' is dangerous and not supported. Instead, see README for how to integrate Google Test into your build system." - false - -install-data-local: - echo "'make install' is dangerous and not supported. Instead, see README for how to integrate Google Test into your build system." - false