init repo.
This commit is contained in:
209
third_party/gflags/test/CMakeLists.txt
vendored
Normal file
209
third_party/gflags/test/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,209 @@
|
||||
## gflags tests
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# output directories
|
||||
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
|
||||
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
|
||||
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
|
||||
|
||||
# set working directory of test commands
|
||||
set (GFLAGS_FLAGFILES_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# common include directories and link libraries
|
||||
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
include_directories ("${gflags_SOURCE_DIR}/src")
|
||||
include_directories ("${gflags_BINARY_DIR}/include")
|
||||
include_directories ("${gflags_BINARY_DIR}/include/gflags")
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
set (type shared)
|
||||
if (GFLAGS_IS_A_DLL)
|
||||
add_definitions(-DGFLAGS_IS_A_DLL)
|
||||
endif ()
|
||||
else ()
|
||||
set (type static)
|
||||
endif ()
|
||||
if (BUILD_gflags_LIB)
|
||||
link_libraries (gflags_${type})
|
||||
else ()
|
||||
link_libraries (gflags_nothreads_${type})
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# STRIP_FLAG_HELP
|
||||
add_executable (gflags_strip_flags_test gflags_strip_flags_test.cc)
|
||||
# Make sure the --help output doesn't print the stripped text.
|
||||
add_gflags_test (strip_flags_help 1 "" "This text should be stripped out" gflags_strip_flags_test --help)
|
||||
# Make sure the stripped text isn't in the binary at all.
|
||||
add_test (
|
||||
NAME strip_flags_binary
|
||||
COMMAND "${CMAKE_COMMAND}" "-DBINARY=$<TARGET_FILE:gflags_strip_flags_test>"
|
||||
-P "${CMAKE_CURRENT_SOURCE_DIR}/gflags_strip_flags_test.cmake"
|
||||
CONFIGURATIONS Release MinSizeRel
|
||||
)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# unit tests
|
||||
configure_file (gflags_unittest.cc gflags_unittest-main.cc COPYONLY)
|
||||
configure_file (gflags_unittest.cc gflags_unittest_main.cc COPYONLY)
|
||||
|
||||
add_executable (gflags_unittest gflags_unittest.cc)
|
||||
add_executable (gflags_unittest-main gflags_unittest-main.cc)
|
||||
add_executable (gflags_unittest_main gflags_unittest_main.cc)
|
||||
|
||||
if (OS_WINDOWS)
|
||||
set (SLASH "\\\\")
|
||||
else ()
|
||||
set (SLASH "/")
|
||||
endif ()
|
||||
|
||||
# First, just make sure the gflags_unittest works as-is
|
||||
add_gflags_test(unittest 0 "" "" gflags_unittest)
|
||||
|
||||
# --help should show all flags, including flags from gflags_reporting
|
||||
add_gflags_test(help-reporting 1 "${SLASH}gflags_reporting.cc:" "" gflags_unittest --help)
|
||||
|
||||
# Make sure that --help prints even very long helpstrings.
|
||||
add_gflags_test(long-helpstring 1 "end of a long helpstring" "" gflags_unittest --help)
|
||||
|
||||
# Make sure --help reflects flag changes made before flag-parsing
|
||||
add_gflags_test(changed_bool1 1 "-changed_bool1 (changed) type: bool default: true" "" gflags_unittest --help)
|
||||
add_gflags_test(changed_bool2 1 "-changed_bool2 (changed) type: bool default: false currently: true" "" gflags_unittest --help)
|
||||
# And on the command-line, too
|
||||
add_gflags_test(changeable_string_var 1 "-changeable_string_var () type: string default: \"1\" currently: \"2\"" "" gflags_unittest --changeable_string_var 2 --help)
|
||||
|
||||
# --nohelp and --help=false should be as if we didn't say anything
|
||||
add_gflags_test(nohelp 0 "PASS" "" gflags_unittest --nohelp)
|
||||
add_gflags_test(help=false 0 "PASS" "" gflags_unittest --help=false)
|
||||
|
||||
# --helpfull is the same as help
|
||||
add_gflags_test(helpfull 1 "${SLASH}gflags_reporting.cc:" "" gflags_unittest --helpfull)
|
||||
|
||||
# --helpshort should show only flags from the gflags_unittest itself
|
||||
add_gflags_test(helpshort 1 "${SLASH}gflags_unittest.cc:" "${SLASH}gflags_reporting.cc:" gflags_unittest --helpshort)
|
||||
|
||||
# --helpshort should show the tldflag we created in the gflags_unittest dir
|
||||
add_gflags_test(helpshort-tldflag1 1 "tldflag1" "${SLASH}google.cc:" gflags_unittest --helpshort)
|
||||
add_gflags_test(helpshort-tldflag2 1 "tldflag2" "${SLASH}google.cc:" gflags_unittest --helpshort)
|
||||
|
||||
# --helpshort should work if the main source file is suffixed with [_-]main
|
||||
add_gflags_test(helpshort-main 1 "${SLASH}gflags_unittest-main.cc:" "${SLASH}gflags_reporting.cc:" gflags_unittest-main --helpshort)
|
||||
add_gflags_test(helpshort_main 1 "${SLASH}gflags_unittest_main.cc:" "${SLASH}gflags_reporting.cc:" gflags_unittest_main --helpshort)
|
||||
|
||||
# --helpon needs an argument
|
||||
add_gflags_test(helpon 1 "'--helpon' is missing its argument; flag description: show help on" "" gflags_unittest --helpon)
|
||||
# --helpon argument indicates what file we'll show args from
|
||||
add_gflags_test(helpon=gflags 1 "${SLASH}gflags.cc:" "${SLASH}gflags_unittest.cc:" gflags_unittest --helpon=gflags)
|
||||
# another way of specifying the argument
|
||||
add_gflags_test(helpon_gflags 1 "${SLASH}gflags.cc:" "${SLASH}gflags_unittest.cc:" gflags_unittest --helpon gflags)
|
||||
# test another argument
|
||||
add_gflags_test(helpon=gflags_unittest 1 "${SLASH}gflags_unittest.cc:" "${SLASH}gflags.cc:" gflags_unittest --helpon=gflags_unittest)
|
||||
|
||||
# helpmatch is like helpon but takes substrings
|
||||
add_gflags_test(helpmatch_reporting 1 "${SLASH}gflags_reporting.cc:" "${SLASH}gflags_unittest.cc:" gflags_unittest -helpmatch reporting)
|
||||
add_gflags_test(helpmatch=unittest 1 "${SLASH}gflags_unittest.cc:" "${SLASH}gflags.cc:" gflags_unittest -helpmatch=unittest)
|
||||
|
||||
# if no flags are found with helpmatch or helpon, suggest --help
|
||||
add_gflags_test(helpmatch=nosuchsubstring 1 "No modules matched" "${SLASH}gflags_unittest.cc:" gflags_unittest -helpmatch=nosuchsubstring)
|
||||
add_gflags_test(helpon=nosuchmodule 1 "No modules matched" "${SLASH}gflags_unittest.cc:" gflags_unittest -helpon=nosuchmodule)
|
||||
|
||||
# helppackage shows all the flags in the same dir as this unittest
|
||||
# --help should show all flags, including flags from google.cc
|
||||
add_gflags_test(helppackage 1 "${SLASH}gflags_reporting.cc:" "" gflags_unittest --helppackage)
|
||||
|
||||
# xml!
|
||||
add_gflags_test(helpxml 1 "${SLASH}gflags_unittest.cc</file>" "${SLASH}gflags_unittest.cc:" gflags_unittest --helpxml)
|
||||
|
||||
# just print the version info and exit
|
||||
add_gflags_test(version-1 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest --version)
|
||||
add_gflags_test(version-2 0 "version test_version" "${SLASH}gflags_unittest.cc:" gflags_unittest --version)
|
||||
|
||||
# --undefok is a fun flag...
|
||||
add_gflags_test(undefok-1 1 "unknown command line flag 'foo'" "" gflags_unittest --undefok= --foo --unused_bool)
|
||||
add_gflags_test(undefok-2 0 "PASS" "" gflags_unittest --undefok=foo --foo --unused_bool)
|
||||
# If you say foo is ok to be undefined, we'll accept --nofoo as well
|
||||
add_gflags_test(undefok-3 0 "PASS" "" gflags_unittest --undefok=foo --nofoo --unused_bool)
|
||||
# It's ok if the foo is in the middle
|
||||
add_gflags_test(undefok-4 0 "PASS" "" gflags_unittest --undefok=fee,fi,foo,fum --foo --unused_bool)
|
||||
# But the spelling has to be just right...
|
||||
add_gflags_test(undefok-5 1 "unknown command line flag 'foo'" "" gflags_unittest --undefok=fo --foo --unused_bool)
|
||||
add_gflags_test(undefok-6 1 "unknown command line flag 'foo'" "" gflags_unittest --undefok=foot --foo --unused_bool)
|
||||
|
||||
# See if we can successfully load our flags from the flagfile
|
||||
add_gflags_test(flagfile.1 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest "--flagfile=flagfile.1")
|
||||
add_gflags_test(flagfile.2 0 "PASS" "" gflags_unittest "--flagfile=flagfile.2")
|
||||
add_gflags_test(flagfile.3 0 "PASS" "" gflags_unittest "--flagfile=flagfile.3")
|
||||
|
||||
# Also try to load flags from the environment
|
||||
add_gflags_test(fromenv=version 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest --fromenv=version)
|
||||
add_gflags_test(tryfromenv=version 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest --tryfromenv=version)
|
||||
add_gflags_test(fromenv=help 0 "PASS" "" gflags_unittest --fromenv=help)
|
||||
add_gflags_test(tryfromenv=help 0 "PASS" "" gflags_unittest --tryfromenv=help)
|
||||
add_gflags_test(fromenv=helpfull 1 "helpfull not found in environment" "" gflags_unittest --fromenv=helpfull)
|
||||
add_gflags_test(tryfromenv=helpfull 0 "PASS" "" gflags_unittest --tryfromenv=helpfull)
|
||||
add_gflags_test(tryfromenv=undefok 0 "PASS" "" gflags_unittest --tryfromenv=undefok --foo)
|
||||
add_gflags_test(tryfromenv=weirdo 1 "unknown command line flag" "" gflags_unittest --tryfromenv=weirdo)
|
||||
add_gflags_test(tryfromenv-multiple 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest --tryfromenv=test_bool,version,unused_bool)
|
||||
add_gflags_test(fromenv=test_bool 1 "not found in environment" "" gflags_unittest --fromenv=test_bool)
|
||||
add_gflags_test(fromenv=test_bool-ok 1 "unknown command line flag" "" gflags_unittest --fromenv=test_bool,ok)
|
||||
# Here, the --version overrides the fromenv
|
||||
add_gflags_test(version-overrides-fromenv 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest --fromenv=test_bool,version,ok)
|
||||
|
||||
# Make sure -- by itself stops argv processing
|
||||
add_gflags_test(dashdash 0 "PASS" "" gflags_unittest -- --help)
|
||||
|
||||
# And we should die if the flag value doesn't pass the validator
|
||||
add_gflags_test(always_fail 1 "ERROR: failed validation of new value 'true' for flag 'always_fail'" "" gflags_unittest --always_fail)
|
||||
|
||||
# And if locking in validators fails
|
||||
# TODO(andreas): Worked on Windows 7 Release configuration, but causes
|
||||
# debugger abort() intervention in case of Debug configuration.
|
||||
#add_gflags_test(deadlock_if_cant_lock 0 "PASS" "" gflags_unittest --deadlock_if_cant_lock)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# use gflags_declare.h
|
||||
add_executable (gflags_declare_test gflags_declare_test.cc gflags_declare_flags.cc)
|
||||
|
||||
add_test(NAME gflags_declare COMMAND gflags_declare_test --message "Hello gflags!")
|
||||
set_tests_properties(gflags_declare PROPERTIES PASS_REGULAR_EXPRESSION "Hello gflags!")
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# configure Python script which configures and builds a test project
|
||||
if (BUILD_NC_TESTS OR BUILD_CONFIG_TESTS)
|
||||
find_package (PythonInterp)
|
||||
if (NOT PYTHON_EXECUTABLE)
|
||||
message (FATAL_ERROR "No Python installation found! It is required by the (negative) compilation tests."
|
||||
" Either install Python or set BUILD_NC_TESTS and BUILD_CONFIG_TESTS to FALSE.")
|
||||
endif ()
|
||||
set (TMPDIR "${PROJECT_BINARY_DIR}/Testing/Temporary")
|
||||
configure_file (gflags_build.py.in "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/build.py" @ONLY)
|
||||
function (add_gflags_build_test name srcdir expect_fail)
|
||||
set (srcdir "${CMAKE_CURRENT_SOURCE_DIR}/${srcdir}")
|
||||
add_test (
|
||||
NAME "${name}"
|
||||
COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/build.py"
|
||||
${name} ${srcdir} ${expect_fail}
|
||||
)
|
||||
endfunction ()
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# negative compilation tests
|
||||
option (BUILD_NC_TESTS "Request addition of negative compilation tests." OFF)
|
||||
mark_as_advanced (BUILD_NC_TESTS)
|
||||
if (BUILD_NC_TESTS)
|
||||
add_gflags_build_test (nc_sanity nc 0)
|
||||
add_gflags_build_test (nc_swapped_args nc 1)
|
||||
add_gflags_build_test (nc_int_instead_of_bool nc 1)
|
||||
add_gflags_build_test (nc_bool_in_quotes nc 1)
|
||||
add_gflags_build_test (nc_define_string_with_0 nc 1)
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# build configuration test
|
||||
option (BUILD_CONFIG_TESTS "Request addition of package configuration tests." OFF)
|
||||
mark_as_advanced (BUILD_CONFIG_TESTS)
|
||||
if (BUILD_CONFIG_TESTS)
|
||||
add_gflags_build_test (cmake_config config 0)
|
||||
endif ()
|
10
third_party/gflags/test/config/CMakeLists.txt
vendored
Normal file
10
third_party/gflags/test/config/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
## gflags package configuration tests
|
||||
|
||||
cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
|
||||
|
||||
project (gflags_${TEST_NAME})
|
||||
|
||||
find_package (gflags REQUIRED)
|
||||
|
||||
add_executable (foo main.cc)
|
||||
target_link_libraries (foo gflags::gflags)
|
20
third_party/gflags/test/config/main.cc
vendored
Normal file
20
third_party/gflags/test/config/main.cc
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
#include <iostream>
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
DEFINE_string(message, "Hello World!", "The message to print");
|
||||
|
||||
static bool ValidateMessage(const char* flagname, const std::string &message)
|
||||
{
|
||||
return !message.empty();
|
||||
}
|
||||
DEFINE_validator(message, ValidateMessage);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
gflags::SetUsageMessage("Test CMake configuration of gflags library (gflags-config.cmake)");
|
||||
gflags::SetVersionString("0.1");
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
std::cout << FLAGS_message << std::endl;
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
return 0;
|
||||
}
|
1
third_party/gflags/test/flagfile.1
vendored
Normal file
1
third_party/gflags/test/flagfile.1
vendored
Normal file
@ -0,0 +1 @@
|
||||
--version
|
2
third_party/gflags/test/flagfile.2
vendored
Normal file
2
third_party/gflags/test/flagfile.2
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
--foo=bar
|
||||
--nounused_bool
|
1
third_party/gflags/test/flagfile.3
vendored
Normal file
1
third_party/gflags/test/flagfile.3
vendored
Normal file
@ -0,0 +1 @@
|
||||
--flagfile=flagfile.2
|
43
third_party/gflags/test/gflags_build.py.in
vendored
Normal file
43
third_party/gflags/test/gflags_build.py.in
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import shutil
|
||||
|
||||
CMAKE = '@CMAKE_COMMAND@'
|
||||
CMAKE_BUILD_TYPE = '@CMAKE_BUILD_TYPE@'
|
||||
TMPDIR = '@TMPDIR@'
|
||||
SRCDIR = '@SRCDIR@'
|
||||
GFLAGS_DIR = '@gflags_BINARY_DIR@'
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 4:
|
||||
sys.stderr.write(' '.join(['usage:', sys.argv[0], '<test_name> <srcdir> <expect_fail:0|1>\n']))
|
||||
sys.exit(1)
|
||||
test_name = sys.argv[1]
|
||||
srcdir = sys.argv[2]
|
||||
expect_fail = (sys.argv[3].lower() in ['true', 'yes', 'on', '1'])
|
||||
bindir = os.path.join(TMPDIR, test_name)
|
||||
if TMPDIR == '':
|
||||
sys.stderr.write('Temporary directory not set!\n')
|
||||
sys.exit(1)
|
||||
# create build directory
|
||||
if os.path.isdir(bindir): shutil.rmtree(bindir)
|
||||
os.makedirs(bindir)
|
||||
# configure the build tree
|
||||
if subprocess.call([CMAKE, '-DCMAKE_BUILD_TYPE:STRING='+CMAKE_BUILD_TYPE,
|
||||
'-Dgflags_DIR:PATH='+GFLAGS_DIR,
|
||||
'-DTEST_NAME:STRING='+test_name, srcdir], cwd=bindir) != 0:
|
||||
sys.stderr.write('Failed to configure the build tree!\n')
|
||||
sys.exit(1)
|
||||
# build the test project
|
||||
exit_code = subprocess.call([CMAKE, '--build', bindir, '--config', CMAKE_BUILD_TYPE], cwd=bindir)
|
||||
if expect_fail == True:
|
||||
if exit_code == 0:
|
||||
sys.stderr.write('Build expected to fail, but it succeeded!\n')
|
||||
sys.exit(1)
|
||||
else:
|
||||
sys.stderr.write('Build failed as expected\n')
|
||||
exit_code = 0
|
||||
sys.exit(exit_code)
|
12
third_party/gflags/test/gflags_declare_flags.cc
vendored
Executable file
12
third_party/gflags/test/gflags_declare_flags.cc
vendored
Executable file
@ -0,0 +1,12 @@
|
||||
#define GFLAGS_DLL_DECLARE_FLAG
|
||||
|
||||
#include <iostream>
|
||||
#include <gflags/gflags_declare.h>
|
||||
|
||||
DECLARE_string(message); // in gflags_delcare_test.cc
|
||||
|
||||
void print_message();
|
||||
void print_message()
|
||||
{
|
||||
std::cout << FLAGS_message << std::endl;
|
||||
}
|
12
third_party/gflags/test/gflags_declare_test.cc
vendored
Normal file
12
third_party/gflags/test/gflags_declare_test.cc
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
DEFINE_string(message, "", "The message to print");
|
||||
void print_message(); // in gflags_declare_flags.cc
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GFLAGS_NAMESPACE::SetUsageMessage("Test compilation and use of gflags_declare.h");
|
||||
GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
|
||||
print_message();
|
||||
return 0;
|
||||
}
|
60
third_party/gflags/test/gflags_strip_flags_test.cc
vendored
Executable file
60
third_party/gflags/test/gflags_strip_flags_test.cc
vendored
Executable file
@ -0,0 +1,60 @@
|
||||
// Copyright (c) 2011, 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.
|
||||
//
|
||||
// ---
|
||||
// Author: csilvers@google.com (Craig Silverstein)
|
||||
//
|
||||
// A simple program that uses STRIP_FLAG_HELP. We'll have a shell
|
||||
// script that runs 'strings' over this program and makes sure
|
||||
// that the help string is not in there.
|
||||
|
||||
#define STRIP_FLAG_HELP 1
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
using GFLAGS_NAMESPACE::SetUsageMessage;
|
||||
using GFLAGS_NAMESPACE::ParseCommandLineFlags;
|
||||
|
||||
|
||||
DEFINE_bool(test, true, "This text should be stripped out");
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
SetUsageMessage("Usage message");
|
||||
ParseCommandLineFlags(&argc, &argv, false);
|
||||
|
||||
// Unfortunately, for us, libtool can replace executables with a shell
|
||||
// script that does some work before calling the 'real' executable
|
||||
// under a different name. We need the 'real' executable name to run
|
||||
// 'strings' on it, so we construct this binary to print the real
|
||||
// name (argv[0]) on stdout when run.
|
||||
puts(argv[0]);
|
||||
|
||||
return 0;
|
||||
}
|
7
third_party/gflags/test/gflags_strip_flags_test.cmake
vendored
Normal file
7
third_party/gflags/test/gflags_strip_flags_test.cmake
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
if (NOT BINARY)
|
||||
message (FATAL_ERROR "BINARY file to check not specified!")
|
||||
endif ()
|
||||
file (STRINGS "${BINARY}" strings REGEX "This text should be stripped out")
|
||||
if (strings)
|
||||
message (FATAL_ERROR "Text not stripped from binary like it should be: ${BINARY}")
|
||||
endif ()
|
1572
third_party/gflags/test/gflags_unittest.cc
vendored
Executable file
1572
third_party/gflags/test/gflags_unittest.cc
vendored
Executable file
File diff suppressed because it is too large
Load Diff
2
third_party/gflags/test/gflags_unittest_flagfile
vendored
Normal file
2
third_party/gflags/test/gflags_unittest_flagfile
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
--test_flag=1
|
||||
--test_flag=2
|
16
third_party/gflags/test/nc/CMakeLists.txt
vendored
Normal file
16
third_party/gflags/test/nc/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
## gflags negative compilation tests
|
||||
|
||||
cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
|
||||
|
||||
if (NOT TEST_NAME)
|
||||
message (FATAL_ERROR "Missing TEST_NAME CMake flag")
|
||||
endif ()
|
||||
string (TOUPPER ${TEST_NAME} TEST_NAME_UPPER)
|
||||
|
||||
project (gflags_${TEST_NAME})
|
||||
|
||||
find_package (gflags REQUIRED)
|
||||
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
add_definitions (-DTEST_${TEST_NAME_UPPER})
|
||||
add_executable (gflags_${TEST_NAME} gflags_nc.cc)
|
||||
target_link_libraries(gflags_${TEST_NAME} gflags)
|
73
third_party/gflags/test/nc/gflags_nc.cc
vendored
Normal file
73
third_party/gflags/test/nc/gflags_nc.cc
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
// 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_NC_SWAPPED_ARGS)
|
||||
|
||||
DEFINE_bool(some_bool_flag,
|
||||
"the default value should go here, not the description",
|
||||
false);
|
||||
|
||||
|
||||
#elif defined(TEST_NC_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_NC_BOOL_IN_QUOTES)
|
||||
|
||||
|
||||
DEFINE_bool(some_bool_flag_3,
|
||||
"false",
|
||||
"false in in quotes, which is wrong");
|
||||
|
||||
#elif defined(TEST_NC_SANITY)
|
||||
|
||||
DEFINE_bool(some_bool_flag_4,
|
||||
true,
|
||||
"this is the correct usage of DEFINE_bool");
|
||||
|
||||
#elif defined(TEST_NC_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;
|
||||
}
|
Reference in New Issue
Block a user