[Lldb-commits] [lldb] r218422 - The beginnings of a gtest-based test framework.

Todd Fiala tfiala at google.com
Thu Sep 25 07:34:00 PDT 2014


> Maybe it would be better to make a parallel gtest directory, so the
unittest2 framework crawler doesn't accidentally find its way into any of
these tests.

I'm expecting we'll push things around a bit.  gtest at the top level
sounds reasonable to me.

> Also, can you think of a better outer directory name than c++?

I think gtest at the top level covers this.  Sound reasonable?

> I would naively think some of the lang/cpp tests had wandered their way
out of their proper directory...

Agreed.

Any thoughts on the structure underneath gtest?  My personal objectives are
to be able to unit test low-level code that is hard to test via the more
high level system tests that we do with Python.  I don't anticipate there
will be a lot of tests in here (relatively speaking).  Certainly on my end
it's just a handful of classes.

-Todd

On Wed, Sep 24, 2014 at 4:17 PM, <jingham at apple.com> wrote:

> Maybe it would be better to make a parallel gtest directory, so the
> unittest2 framework crawler doesn't accidentally find its way into any of
> these tests.  Also, can you think of a better outer directory name than
> c++?  I assume that name choice is because these are white box tests of the
> lldb_private C++ API, but I don't think that would be obvious to anyone
> looking at the directories.  I would naively think some of the lang/cpp
> tests had wandered their way out of their proper directory...
>
> Jim
>
>
> > On Sep 24, 2014, at 3:57 PM, Todd Fiala <todd.fiala at gmail.com> wrote:
> >
> > Author: tfiala
> > Date: Wed Sep 24 17:57:33 2014
> > New Revision: 218422
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=218422&view=rev
> > Log:
> > The beginnings of a gtest-based test framework.
> >
> > Makes use of LLVM gtest support.  This does *not* run as part of
> > the lldb test suite.
> >
> > I'm using it to start testing some components that
> > I'll be adding to the inner guts of NativeThreadLinux to more
> > maintainably handle thread states and deferred thread state notification.
> >
> > Runs with default Makefile target "test" using gmake within a given
> > test directory (currently only
> test/c++/native_process/thread_state_coordinator).
> >
> > The Makefile.rules currently assume it is using the LLVM gtest.  It
> works on
> > a canonical MacOSX dir structture (i.e. lldb, lldb/llvm,
> lldb/llvm/tools/clang).
> > It also works on Ubuntu assuming the standard dir layout of llvm,
> llvm/tools/clang,
> > llvm/tools/lldb.  In this case, it expects a directory called
> build-debug parallel
> > to the llvm source dir.  All directory assumptions can be overridden with
> > environment variables.  See test/c++/make/Makefile.rules for details.
> >
> > We'll want to make this smarter in the future, particularly around
> finding the LLVM build
> > output dir.
> >
> > Added:
> >    lldb/trunk/test/c++/
> >    lldb/trunk/test/c++/make/
> >    lldb/trunk/test/c++/make/Makefile.rules
> >    lldb/trunk/test/c++/native_process/
> >    lldb/trunk/test/c++/native_process/thread_state_coordinator/
> >    lldb/trunk/test/c++/native_process/thread_state_coordinator/Makefile
> >
> lldb/trunk/test/c++/native_process/thread_state_coordinator/ThreadStateCoordinatorTest.cpp
> >
> > Added: lldb/trunk/test/c++/make/Makefile.rules
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/test/c%2B%2B/make/Makefile.rules?rev=218422&view=auto
> >
> ==============================================================================
> > --- lldb/trunk/test/c++/make/Makefile.rules (added)
> > +++ lldb/trunk/test/c++/make/Makefile.rules Wed Sep 24 17:57:33 2014
> > @@ -0,0 +1,58 @@
> > +# Retrieve this Makefile's location.
> > +THIS_FILE_DIR := $(shell dirname $(realpath $(lastword
> $(MAKEFILE_LIST))))/
> > +
> > +# Set default target to be test
> > +.DEFAULT_GOAL := test
> > +
> > +# Set up GTEST for canonical Linux and MacOSX source trees.
> > +ifeq ($(wildcard ../../../../llvm/utils/unittest/googletest),)
> > +    # Assume llvm/tools/lldb (Non-MacOSX) directory form.
> > +    LLVM_BASE_DIR := $(realpath ../../../../../..)
> > +else
> > +    # Assume lldb/llvm (MacOSX Xcode) directory form.
> > +    LLVM_BASE_DIR := $(realpath ../../../../llvm)
> > +endif
> > +
> > +ifeq ($(GTEST_DIR),)
> > +    GTEST_DIR := $(LLVM_BASE_DIR)/utils/unittest/googletest
> > +endif
> > +GTEST_INCLUDE_DIR := $(GTEST_DIR)/include
> > +
> > +ifeq ($(LLVM_BUILD_DIR),)
> > +    ifneq ($(wildcard
> $(THIS_FILE_DIR)../../../llvm-build/Release+Asserts/x86_64/Release+Asserts),)
> > +        LLVM_BUILD_DIR := $(realpath
> $(THIS_FILE_DIR)../../../llvm-build/Release+Asserts/x86_64/Release+Asserts)
> > +    else ifneq ($(wildcard
> $(THIS_FILE_DIR)../../../../../../build-debug/lib),)
> > +        LLVM_BUILD_DIR := $(realpath
> $(THIS_FILE_DIR)../../../../../../build-debug)
> > +    endif
> > +endif
> > +
> > +ifeq ($(LLVM_BUILD_DIR),)
> > +    $(error Could not find LLVM build output dir, please set it with
> LLVM_BUILD_DIR)
> > +endif
> > +GTEST_STATIC_LIB_DIR := $(LLVM_BUILD_DIR)/lib
> > +
> > +ifeq ($(LLVM_BUILD_INCLUDE_DIR),)
> > +    ifneq ($(wildcard $(LLVM_BUILD_DIR)/../include),)
> > +        LLVM_BUILD_INCLUDE_DIR := $(realpath
> $(LLVM_BUILD_DIR)/../include)
> > +    else ifneq ($(wildcard $(LLVM_BUILD_DIR)/include),)
> > +        LLVM_BUILD_INCLUDE_DIR := $(realpath $(LLVM_BUILD_DIR)/include)
> > +    endif
> > +endif
> > +
> > +ifeq ($(LLVM_BUILD_INCLUDE_DIR),)
> > +    $(error Could not find LLVM build directory include dir, please set
> it with LLVM_BUILD_INCLUDE_DIR)
> > +endif
> > +
> > +$(info LLVM_BASE_DIR = $(LLVM_BASE_DIR))
> > +$(info LLVM_BUILD_DIR = $(LLVM_BUILD_DIR))
> > +$(info GTEST_DIR = $(GTEST_DIR))
> > +$(info GTEST_INCLUDE_DIR = $(GTEST_INCLUDE_DIR))
> > +$(info GTEST_STATIC_LIB_DIR = $(GTEST_STATIC_LIB_DIR))
> > +
> > +CFLAGS_EXTRAS += -I $(GTEST_INCLUDE_DIR) -I $(LLVM_BASE_DIR)/include -I
> $(LLVM_BUILD_INCLUDE_DIR)
> > +LD_EXTRAS += $(GTEST_STATIC_LIB_DIR)/libgtest.a
> $(GTEST_STATIC_LIB_DIR)/libgtest_main.a
> $(GTEST_STATIC_LIB_DIR)/libLLVMSupport.a
> > +
> > +include $(THIS_FILE_DIR)../../make/Makefile.rules
> > +
> > +test:: $(EXE)
> > +     $(realpath $(EXE))
> >
> > Added:
> lldb/trunk/test/c++/native_process/thread_state_coordinator/Makefile
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/test/c%2B%2B/native_process/thread_state_coordinator/Makefile?rev=218422&view=auto
> >
> ==============================================================================
> > --- lldb/trunk/test/c++/native_process/thread_state_coordinator/Makefile
> (added)
> > +++ lldb/trunk/test/c++/native_process/thread_state_coordinator/Makefile
> Wed Sep 24 17:57:33 2014
> > @@ -0,0 +1,14 @@
> > +LEVEL = ../../make
> > +
> > +CFLAGS_EXTRAS := -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS
> -D__STDC_CONSTANT_MACROS
> > +ENABLE_THREADS := YES
> > +CXX_SOURCES := $(wildcard *.cpp)
> > +MAKE_DSYM :=NO
> > +
> > +OS := $(shell uname -s)
> > +$(info OS $(OS))
> > +ifeq ($(OS),Linux)
> > +    LD_EXTRAS += -lncurses -ldl
> > +endif
> > +
> > +include $(LEVEL)/Makefile.rules
> >
> > Added:
> lldb/trunk/test/c++/native_process/thread_state_coordinator/ThreadStateCoordinatorTest.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/test/c%2B%2B/native_process/thread_state_coordinator/ThreadStateCoordinatorTest.cpp?rev=218422&view=auto
> >
> ==============================================================================
> > ---
> lldb/trunk/test/c++/native_process/thread_state_coordinator/ThreadStateCoordinatorTest.cpp
> (added)
> > +++
> lldb/trunk/test/c++/native_process/thread_state_coordinator/ThreadStateCoordinatorTest.cpp
> Wed Sep 24 17:57:33 2014
> > @@ -0,0 +1,7 @@
> > +#include <limits.h>
> > +#include "gtest/gtest.h"
> > +
> > +TEST(ThreadStateCoordinatorTest, ExpectEqualsWorks)
> > +{
> > +     EXPECT_EQ(1, 1);
> > +}
> >
> >
> > _______________________________________________
> > lldb-commits mailing list
> > lldb-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
>



-- 
Todd Fiala | Software Engineer | tfiala at google.com | 650-943-3180
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20140925/639eceeb/attachment.html>


More information about the lldb-commits mailing list