1fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville#!/usr/bin/env python 2fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# 3fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# Copyright 2008, Google Inc. 4fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# All rights reserved. 5fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# 6fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# Redistribution and use in source and binary forms, with or without 7fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# modification, are permitted provided that the following conditions are 8fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# met: 9fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# 10fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# * Redistributions of source code must retain the above copyright 11fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# notice, this list of conditions and the following disclaimer. 12fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# * Redistributions in binary form must reproduce the above 13fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# copyright notice, this list of conditions and the following disclaimer 14fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# in the documentation and/or other materials provided with the 15fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# distribution. 16fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# * Neither the name of Google Inc. nor the names of its 17fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# contributors may be used to endorse or promote products derived from 18fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# this software without specific prior written permission. 19fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# 20fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 32fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville"""Verifies that Google Test warns the user when not initialized properly.""" 33fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 34fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville__author__ = 'wan@google.com (Zhanyong Wan)' 35fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 36fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savilleimport gtest_test_utils 37fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 38fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 39fbaaef999ba563838ebd00874ed8a1c01fbf286dWink SavilleCOMMAND = gtest_test_utils.GetTestExecutablePath('gtest_uninitialized_test_') 40fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 41fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 42fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savilledef Assert(condition): 43fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville if not condition: 44fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville raise AssertionError 45fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 46fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 47fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savilledef AssertEq(expected, actual): 48fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville if expected != actual: 49fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville print 'Expected: %s' % (expected,) 50fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville print ' Actual: %s' % (actual,) 51fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville raise AssertionError 52fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 53fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 54fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savilledef TestExitCodeAndOutput(command): 55fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville """Runs the given command and verifies its exit code and output.""" 56fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 57fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville # Verifies that 'command' exits with code 1. 58fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville p = gtest_test_utils.Subprocess(command) 59fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville Assert(p.exited) 60fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville AssertEq(1, p.exit_code) 61fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville Assert('InitGoogleTest' in p.output) 62fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 63fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 64fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savilleclass GTestUninitializedTest(gtest_test_utils.TestCase): 65fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville def testExitCodeAndOutput(self): 66fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville TestExitCodeAndOutput(COMMAND) 67fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 68fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville 69fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Savilleif __name__ == '__main__': 70fbaaef999ba563838ebd00874ed8a1c01fbf286dWink Saville gtest_test_utils.Main() 71