pax_global_header00006660000000000000000000000064146553105230014516gustar00rootroot0000000000000052 comment=31d84db137823bc4f037133d9e15c068a2dc5822 SkyPat-3.2.0/000077500000000000000000000000001465531052300127335ustar00rootroot00000000000000SkyPat-3.2.0/.gitignore000066400000000000000000000003371465531052300147260ustar00rootroot00000000000000autom4te.cache Makefile.in aclocal.m4 configure libtool.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 lt~obsolete.m4 output.* traces.* requests config.log config.status .deps .dirstamp *.o *.lo Makefile stamp-h1 .libs libtool *~ SkyPat-3.2.0/ChangeLog000066400000000000000000000043061465531052300145100ustar00rootroot000000000000002024-08-09 Cheng-Chi Wang * Executive Summary: 1. Add FindSkyPat CMake config 2. Add SKYPAT_SYSTEMC_F test function. 2018-05-01 Peter Chang * Executive Summary: 1. Remove the white paper due to license issues. 2. Replace pat by SkyPat in the LICENSE file. 3. Make sure that all files' licenses are based on the LICENSE file. 2018-04-08 Peter Chang * Executive Summary: 1. Change some files to fit Debian's policy. 2. Provide ASSERT and EXPECT macros with error messages. 3. Replace Pat/PAT by SkyPat/SKYPAT to unify our project name. * Change some files to fit Debian's policy: 1. Remove some documents with license issues to fit Debian's policy. 2. Remove our homemade debian folder to fit Debian's policy. 2016-12-20 Peter Chang * Executive Summary: 1. Support all general perf_events. 2. Change the interface of PERFORM macros. 2014-08-14 Luba Tang * Executive Summary: 1. Allow program to run particular cases by changing the program name. 2. Add class Path 3. Allow -h to show the help manual. 2014-03-31 Luba Tang * Executive Summary: 1. Add predicate assertion macros - ASSERT_EQ/NE/LT/LE/GT/GE. 2. Enhance the ability to integrate with the other projects via providing m4 scripts. 3. Change all Skymizer trade mark to `pat`. 4. Enhance building system * Ehance building system and directory structure: 1. Add build.sh script to help user to dance with auto tools. 2. Turn the dirctory structure from single file (pat.h/pat.cpp) to multiple files. 3. Clean up .gitignore * Improve usability: 1. Add predicate assertions - ASSERT/EXPECT_EQ/NE/LT/LE/GT/GE 2. Add check_pat.m4 and setup_pat.m4 scripts 2014-02-28 Peter Release in open. 2014-01-23 TDYa127 2.4.2 Fixes timer overflow bug. 2014-01-20 TDYa127 Refine installation process. 2014-01-05 Luba Tang Complete installable tarball. 2013-12-22 Luba Tang To initialize "pat" project and building system 2013-09-18 Luba Tang To create all basic directories and building system SkyPat-3.2.0/INSTALL000066400000000000000000000026461465531052300137740ustar00rootroot00000000000000------------------------------------------------------------------------------ The SkyPat Team ------------------------------------------------------------------------------ ============ Introduction ============ SkyPat is a precise performance test library. ======================== Compilation Instructions ======================== The simplest way to compile this package is: -------------- Build SkyPat -------------- Dance with standard auto-tools. 1. clone Skymizer from the repositry git clone git@github.com:skymizer/skypat.git ${SKYPAT} 2. Type `cd ${SKYPAT}' to the directory containing the source code. 3. If there are no `configure' shell script in the directory, type `./autogen.sh' to generate `configure' script. 4. Type `./configure` to configure the package for your system. See INSTALL for more details. ./configure --prefix=${SKYPAT_INSTALL} \ 5. Type `make` to compile the package 6. Type `make install` to install the package into your system. =================== Directory Structure =================== README - this document Makefile.am - input of automake configure.ac - input of autoconf src/ - source code of verification tool include/ - include file, exported interface lib/ - source code of exported interface examples/ - the place of examples SkyPat-3.2.0/LICENSE000066400000000000000000000027101465531052300137400ustar00rootroot00000000000000Copyright 2014, The SkyPat Team 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 The pat team 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. SkyPat-3.2.0/Makefile.am000066400000000000000000000003051465531052300147650ustar00rootroot00000000000000ACLOCAL_AMFLAGS=-I m4 AUTOMAKE_OPTIONS = foreign SUBDIRS = include lib examples EXTRA_DIST = ./autogen.sh ./LICENSE ./VERSION.in ./ChangeLog ./INSTALL dist_pkgdata_DATA = ./LICENSE ./README.md SkyPat-3.2.0/README.md000066400000000000000000000070371465531052300142210ustar00rootroot00000000000000# The SkyPat Team ----------------------------------------------------------------------------- ## Introduction "SkyPat" is a C++ performance analyzing and testing framework on Android and Linux platforms. It combines perf_events and unit tests together and gives programmers the power of fine-grained performance analysis via writing typical test cases. ## Latest release * v3.1.1 Bourbon - Tarball: https://github.com/skymizer/SkyPat/archive/v3.1.1.tar.gz - Zipball: https://github.com/skymizer/SkyPat/archive/v3.1.1.zip - Debian package: https://packages.debian.org/buster/libskypat-dev (credit: @szlin, @gavin09) ## Directory Structure ``` share/SkyPat/README - this document share/SkyPat/LICENSE - the License share/SkyPat/examples/ - the place of examples include/ - include file, exported interface lib/ - libraries of exported interface ``` ## Supported platforms SkyPat supports macOS, Ubuntu/x86_64, Debian/arm, Fedora/x86_64, Fedora/arm, and CentOS/x86_64. Here is a list of verified versions: * Ubuntu/x86_64 - 14.04 and later versions * Fedora/x86_64 - 20 and later versions * CentOS/x86_64 - 7 and later versions * Debian/arm - 8.6 and later versions ## Getting Started ## Download and build SkyPat You could download **SkyPat** either from the latest release tar-ball or from our `git` repository. ### Method 1: Download **SkyPat** from the latest release tar-ball Download the source code from the latest release tar-ball. $ wget -O SkyPat-3.1.1.tar.gz https://github.com/skymizer/SkyPat/archive/v3.1.1.tar.gz $ tar zxvf SkyPat-3.1.1.tar.gz ### Method 2: Download **SkyPat** from our `git` repository Download the source code from our `git` repository into ${SKYPAT_SRC} directory. $ git clone https://github.com/skymizer/SkyPat.git ${SKYPAT_SRC} ### Install required packages #### Ubuntu/Debian users Install following packages before you install **SkyPat**. $ sudo apt-get install wget automake autoconf libtool build-essential #### Fedora/CentOS users Install following packages before you install **SkyPat**. $ sudo yum install wget automake autoconf libtool make automake gcc gcc-c++ $ sudo yum install kernel-devel ### Build by Auto-tools If there are no `configure` shell script in the directory, use `./autogen.sh` to generate `configure` script. $ ./autogen.sh Use `./configure` to configure the package for your system. See [INSTALL](https://github.com/skymizer/SkyPat/blob/master/INSTALL INSTALL) for more details. $ ./configure --prefix=${SKYPAT_INSTALL} Use `make` to compile the package $ make Type `make install` to install the package into your system. $ make install ### Run Examples Examples of **SkyPat** are installed at ${SKYPAT_INSTALL}/share/skypat/examples. You can go to any sub-directory and build it. For example: cd ${SKYPAT_INSTALL}/share/skypat/examples/assertion make Then, if **SkyPat** is successfully installed, you should see: c++ -I../../../../include -L../../../../lib main.cpp my_case.cpp -lskypat -o assertion LD_LIBRARY_PATH=../../../../lib ./assertion [ SkyPat ] Running 2 tests from 1 cases. [----------] 2 tests from MyCase. [ RUN ] MyCase.fibonacci_test [ OK ] [ RUN ] MyCase.factorial_test [ OK ] [==========] 2 tests from 1 cases ran. [ PASSED ] 2 tests. ## User Guide For those who need more information about **SkyPat**, please check out our [UserGuide](https://github.com/skymizer/SkyPat/wiki/HowToUse) on Github. SkyPat-3.2.0/VERSION.in000066400000000000000000000010101465531052300144000ustar00rootroot00000000000000=================================== "pat" Version @PACKAGE_VERSION@ =================================== Versioning Format: [MAJOR].[MINOR].[AGE] [MAJOR] ALPHA - 0 for alpha BETA - 1 for beta RC - 2 for release candidate FR - 3 for final release MA - 4 for market acceptance GM - 5 for golden model [MINOR] The revision of "pat". Making a release: If any inputs/outputs have been changed, set AGE to 0. If backward compatiblity has been broken, then set AGE to 0, and increase MINOR. SkyPat-3.2.0/autogen.sh000077500000000000000000000004571465531052300147420ustar00rootroot00000000000000#!/bin/sh # The SkyPat Team # LIBTOOLIZE=libtoolize my_uname=`uname` if [ ${my_uname} = "Darwin" ]; then LIBTOOLIZE=glibtoolize fi root=`dirname $0` cd $root aclocal -I ./m4 autoheader ${LIBTOOLIZE} --force automake --add-missing autoconf rm -rf include/pat/Config/Config.h.in~ SkyPat-3.2.0/cmake/000077500000000000000000000000001465531052300140135ustar00rootroot00000000000000SkyPat-3.2.0/cmake/FindSkyPat.cmake000066400000000000000000000012411465531052300170270ustar00rootroot00000000000000##===----------------------------------------------------------------------===## # # The SkyPat Project # # This file is distributed under the Skymizer License. # See LICENSE for details. # ##===----------------------------------------------------------------------===## find_library(SKYPAT_LIBRARIES NAMES skypat HINTS ${SKYPAT_ROOT}/lib ) get_filename_component(SKYPAT_LIBRARY_DIR ${SKYPAT_LIBRARIES} DIRECTORY) find_path(SKYPAT_INCLUDE_DIR NAMES skypat/skypat.h HINTS ${SKYPAT_ROOT}/include ) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(SKYPAT REQUIRED_VARS SKYPAT_INCLUDE_DIR SKYPAT_LIBRARY_DIR) SkyPat-3.2.0/configure.ac000066400000000000000000000055721465531052300152320ustar00rootroot00000000000000############################################################################## # # SkyPat Configuration # # This file is distributed under the New BSD License. # See LICENSE for details. # ############################################################################## #################### # Autoconf/Automake Initialization dnl AC_INIT(PKG_NAME, BUILD_VERSION, BUG_REPORTER) AC_INIT([skypat],[bourbon],[skypat-dev@@googlegroups.com]) AC_PREREQ(2.59) AC_CONFIG_SRCDIR([LICENSE]) AC_CONFIG_AUX_DIR([scripts]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([include/skypat/Config/Config.h]) #################### # Check environments - `host`, `target` and `build` CHECK_CANONICAL_SYSTEM AM_INIT_AUTOMAKE([1.9 dist-bzip2 foreign nostdinc subdir-objects]) #################### # Versioning, see VERSION CURRENT_VERSION=3 REVISION_VERSION=1 AGE_VERSION=0 FULL_VERSION_NAME=Bourbon BUILD_VERSION=bourbon SKYPAT_VERSION=$CURRENT_VERSION:$REVISION_VERSION:$AGE_VERSION PACKAGE_VERSION=$CURRENT_VERSION.$REVISION_VERSION.$AGE_VERSION-$BUILD_VERSION AC_SUBST(PACKAGE_VERSION) AC_SUBST(SKYPAT_VERSION) #################### # Languages AC_PROG_CC AC_PROG_CXX AC_LANG([C++]) AC_CXX_STL_HASH AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc AC_ENABLE_SHARED LT_INIT #################### # Check for compiler warnings CHECK_WERROR_FLAGS CXX_FLAG_CHECK([-Wno-variadic-macros]) #################### # Check for headers AC_CHECK_HEADERS([sys/time.h]) AC_CHECK_HEADERS([linux/perf_event.h]) AC_CHECK_HEADERS([asm/unistd.h]) #################### # Check for functions AC_SEARCH_LIBS([clock_gettime], [rt], [ AC_DEFINE(HAVE_CLOCK_GETTIME, 1,[Have clock_gettime]) ]) AC_CHECK_FUNCS([gettimeofday]) #################### # Check for types AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, intptr_t]) AC_CHECK_TYPES([uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t]) AC_CHECK_TYPES([long double, long long, long long int, unsigned long long int]) AC_CHECK_TYPES([off_t, size_t, ssize_t]) AC_TYPE_LONG_DOUBLE_WIDER #################### # Check for options CHECK_PTHREAD CHECK_ZLIB CHECK_ENABLE_UNITTEST CHECK_ENABLE_OPTIMIZE CHECK_ENABLE_OPTION([clock_gettime], [no], [ENABLE_CLOCK_GETTIME]) CHECK_ENABLE_OPTION([gettimeofday], [yes], [ENABLE_GETTIMEOFDAY]) #################### # OUTPUT AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([include/Makefile]) AC_CONFIG_FILES([lib/Makefile]) AC_CONFIG_FILES([lib/skypat.pc]) AC_CONFIG_FILES([examples/Makefile]) AC_CONFIG_FILES([examples/assertion/Makefile]) AC_CONFIG_FILES([examples/multi_assert/Makefile]) AC_CONFIG_FILES([examples/multi_expect/Makefile]) AC_CONFIG_FILES([examples/multi_case/Makefile]) AC_CONFIG_FILES([examples/performance/Makefile]) AC_CONFIG_FILES([examples/smoke/Makefile]) AC_CONFIG_FILES([examples/fail/Makefile]) AC_CONFIG_FILES([examples/skypat_c/Makefile]) AC_CONFIG_FILES([examples/thread/Makefile]) AC_OUTPUT SkyPat-3.2.0/docs/000077500000000000000000000000001465531052300136635ustar00rootroot00000000000000SkyPat-3.2.0/docs/coscup_2014/000077500000000000000000000000001465531052300156255ustar00rootroot00000000000000SkyPat-3.2.0/docs/coscup_2014/proposal.md000066400000000000000000000031541465531052300200110ustar00rootroot00000000000000長版: SkyPat是一個開源效能分析工具,藉由perf_event與Unit-test,用戶僅需寫test-case,即可透過SkyPat得到程式片段在CPU上運行的指令數,排除OS scheduler的影響。使對運行時間有低誤差容忍的程式,能夠取得實質的執行時間,藉此找出程式運行瓶頸。 過去系統效能分析工具與單元測試工具似乎毫無關係,效能分析多以黑箱測試搭配取樣來量測程式執行效能,但取樣量測無法提供執行Cycle數等級的準確度。而單元測試工具僅針對程式正確性來驗證,無法提供程式片段的效能資訊。 因此,我們開發出一個開源效能分析工具,SkyPat。透過整合Linux perf_event與單元測試,能夠排除程式閒置時間而取得執行Cycle數,藉此找出程式運行瓶頸。 由於對程式片段的Cycle數需要直接由程式本身提供資訊來量測,故我們將擴充單元測試工具,使用者不但可以驗證程式正確性,更能直接插入macro於程式碼中來量測該段程式碼的運行時間。用戶僅需寫測試案例,就可以得到程式片段執行的cycle數,並排除了OS scheduler的影響。 SkyPat已經以New BSD License開源釋出,並已獲bold專案採納做為其效能檢測工具使用。 短版:(100字內) SkyPat是一個開源效能分析工具,藉由perf_event與Unit-test,用戶僅需寫test-case,即可透過SkyPat得到程式片段在CPU上運行的指令數,排除OS scheduler的影響。使對運行時間有低誤差容忍的程式,能夠取得實質的執行時間,藉此找出程式運行瓶頸。 SkyPat-3.2.0/doxygen.cfg000066400000000000000000000246511465531052300151010ustar00rootroot00000000000000# Doxyfile 1.8.3.1 #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- DOXYFILE_ENCODING = UTF-8 PROJECT_NAME = $(PROJECT) PROJECT_NUMBER = $(VERSION) PROJECT_BRIEF = PROJECT_LOGO = OUTPUT_DIRECTORY = $(DOCDIR) CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ABBREVIATE_BRIEF = ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = YES STRIP_FROM_PATH = $(SRCDIR) STRIP_FROM_INC_PATH = $(SRCDIR) SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 2 ALIASES = TCL_SUBST = OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_JAVA = NO OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO EXTENSION_MAPPING = MARKDOWN_SUPPORT = YES AUTOLINK_SUPPORT = YES BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO SIP_SUPPORT = NO IDL_PROPERTY_SUPPORT = YES DISTRIBUTE_GROUP_DOC = NO SUBGROUPING = YES INLINE_GROUPED_CLASSES = NO INLINE_SIMPLE_STRUCTS = NO TYPEDEF_HIDES_STRUCT = NO SYMBOL_CACHE_SIZE = 0 LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- EXTRACT_ALL = NO EXTRACT_PRIVATE = NO EXTRACT_PACKAGE = NO EXTRACT_STATIC = NO EXTRACT_LOCAL_CLASSES = YES EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO HIDE_FRIEND_COMPOUNDS = NO HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO CASE_SENSE_NAMES = YES HIDE_SCOPE_NAMES = NO SHOW_INCLUDE_FILES = YES FORCE_LOCAL_INCLUDES = NO INLINE_INFO = YES SORT_MEMBER_DOCS = YES SORT_BRIEF_DOCS = NO SORT_MEMBERS_CTORS_1ST = NO SORT_GROUP_NAMES = NO SORT_BY_SCOPE_NAME = NO STRICT_PROTO_MATCHING = NO GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES SHOW_FILES = YES SHOW_NAMESPACES = YES FILE_VERSION_FILTER = LAYOUT_FILE = CITE_BIB_FILES = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- QUIET = NO WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = NO WARN_FORMAT = "$file:$line: $text" WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- INPUT = $(SRCDIR) INPUT_ENCODING = UTF-8 FILE_PATTERNS = *.c *.h *.cpp *.hpp *.tcc RECURSIVE = YES EXCLUDE = $(SRCDIR)/unittest $(SRCDIR)/utils/gtest EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = EXCLUDE_SYMBOLS = EXAMPLE_PATH = $(SRCDIR) EXAMPLE_PATTERNS = EXAMPLE_RECURSIVE = YES IMAGE_PATH = INPUT_FILTER = FILTER_PATTERNS = FILTER_SOURCE_FILES = NO FILTER_SOURCE_PATTERNS = USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- SOURCE_BROWSER = NO INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES REFERENCED_BY_RELATION = NO REFERENCES_RELATION = NO REFERENCES_LINK_SOURCE = YES USE_HTAGS = NO VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = YES COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- GENERATE_HTML = $(GENERATE_HTML) HTML_OUTPUT = html HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = HTML_EXTRA_STYLESHEET = HTML_EXTRA_FILES = HTML_COLORSTYLE_HUE = 220 HTML_COLORSTYLE_SAT = 100 HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = NO HTML_DYNAMIC_SECTIONS = NO HTML_INDEX_NUM_ENTRIES = 100 GENERATE_DOCSET = NO DOCSET_FEEDNAME = "Doxygen generated docs" DOCSET_BUNDLE_ID = org.doxygen.Project DOCSET_PUBLISHER_ID = org.doxygen.Publisher DOCSET_PUBLISHER_NAME = Taiwan Evolution Software Technology GENERATE_HTMLHELP = $(GENERATE_CHM) CHM_FILE = ../$(PROJECT).chm HHC_LOCATION = $(HHC_PATH) GENERATE_CHI = $(GENERATE_CHI) CHM_INDEX_ENCODING = BINARY_TOC = NO TOC_EXPAND = NO GENERATE_QHP = NO QCH_FILE = QHP_NAMESPACE = org.doxygen.Project QHP_VIRTUAL_FOLDER = doc QHP_CUST_FILTER_NAME = QHP_CUST_FILTER_ATTRS = QHP_SECT_FILTER_ATTRS = QHG_LOCATION = GENERATE_ECLIPSEHELP = NO ECLIPSE_DOC_ID = org.doxygen.Project DISABLE_INDEX = NO GENERATE_TREEVIEW = NO ENUM_VALUES_PER_LINE = 4 TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 14 FORMULA_TRANSPARENT = YES USE_MATHJAX = NO MATHJAX_FORMAT = HTML-CSS MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest MATHJAX_EXTENSIONS = SEARCHENGINE = NO SERVER_BASED_SEARCH = NO EXTERNAL_SEARCH = NO SEARCHENGINE_URL = SEARCHDATA_FILE = searchdata.xml EXTERNAL_SEARCH_ID = EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- GENERATE_LATEX = $(GENERATE_LATEX) LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO PAPER_TYPE = $(PAPER_SIZE) EXTRA_PACKAGES = LATEX_HEADER = LATEX_FOOTER = PDF_HYPERLINKS = YES USE_PDFLATEX = YES LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO LATEX_SOURCE_CODE = NO LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- GENERATE_RTF = $(GENERATE_RTF) RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- GENERATE_MAN = $(GENERATE_MAN) MAN_OUTPUT = man MAN_EXTENSION = .1 MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = $(GENERATE_XML) XML_OUTPUT = xml XML_SCHEMA = XML_DTD = XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- GENERATE_PERLMOD = NO PERLMOD_LATEX = NO PERLMOD_PRETTY = YES PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES MACRO_EXPANSION = NO EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- TAGFILES = GENERATE_TAGFILE = $(DOCDIR)/$(PROJECT).tag ALLEXTERNALS = NO EXTERNAL_GROUPS = YES PERL_PATH = $(PERL_PATH) #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- CLASS_DIAGRAMS = YES MSCGEN_PATH = HIDE_UNDOC_RELATIONS = YES HAVE_DOT = $(HAVE_DOT) DOT_NUM_THREADS = 0 DOT_FONTNAME = Helvetica DOT_FONTSIZE = 10 DOT_FONTPATH = CLASS_GRAPH = YES COLLABORATION_GRAPH = YES GROUP_GRAPHS = YES UML_LOOK = NO UML_LIMIT_NUM_FIELDS = 10 TEMPLATE_RELATIONS = NO INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES CALL_GRAPH = NO CALLER_GRAPH = NO GRAPHICAL_HIERARCHY = YES DIRECTORY_GRAPH = YES DOT_IMAGE_FORMAT = png INTERACTIVE_SVG = NO DOT_PATH = $(DOT_PATH) DOTFILE_DIRS = MSCFILE_DIRS = DOT_GRAPH_MAX_NODES = 50 MAX_DOT_GRAPH_DEPTH = 0 DOT_TRANSPARENT = NO DOT_MULTI_TARGETS = NO GENERATE_LEGEND = YES DOT_CLEANUP = YES SkyPat-3.2.0/examples/000077500000000000000000000000001465531052300145515ustar00rootroot00000000000000SkyPat-3.2.0/examples/.gitignore000066400000000000000000000002361465531052300165420ustar00rootroot00000000000000assertion/assertion fail/fail multi_assert/multi_assert multi_case/multi_case multi_expect/multi_expect skypat_c/skypat_c performance/performance smoke/smoke SkyPat-3.2.0/examples/Example.mk000066400000000000000000000007331465531052300165000ustar00rootroot00000000000000# TODO: Using M4 or something for readability. SHELL := /usr/bin/env bash define gen_sample_make .PHONY: SampleMakefile SampleMakefile: echo -e 'INCDIR=../../../../include\nLIBDIR=../../../../lib\nrun: $1\n LD_LIBRARY_PATH=$$$$(LIBDIR) ./$$$$<\n$$(strip $1): $(filter-out %.h,$2)\n $$$$(CXX) -I$$$$(INCDIR) -L$$$$(LIBDIR) $$$$^ -fno-rtti -lskypat -o $$$$@\nclean:\n rm -f $1\n' > $$@ install-data-hook: cd $$(DESTDIR)$$($(strip $1)dir) && mv SampleMakefile Makefile endef SkyPat-3.2.0/examples/Makefile.am000066400000000000000000000001741465531052300166070ustar00rootroot00000000000000AUTOMAKE_OPTIONS = foreign SUBDIRS = assertion multi_assert multi_case multi_expect performance smoke fail skypat_c thread SkyPat-3.2.0/examples/assertion/000077500000000000000000000000001465531052300165605ustar00rootroot00000000000000SkyPat-3.2.0/examples/assertion/Makefile.am000066400000000000000000000011061465531052300206120ustar00rootroot00000000000000SKYINCLUDES = -I${abs_top_srcdir}/include \ -I${abs_top_builddir}/include SKYLDFLAGS = -L$(abs_top_builddir)/lib SKY_SOURCES = main.cpp \ my_case.h \ my_case.cpp AM_CPPFLAGS = ${SKYINCLUDES} assertiondir = $(pkgdatadir)/examples/assertion noinst_PROGRAMS = assertion assertion_LDFLAGS = ${SKYLDFLAGS} assertion_LDADD = -lskypat assertion_SOURCES = ${SKY_SOURCES} include ../Example.mk $(eval $(call gen_sample_make, assertion, ${SKY_SOURCES})) dist_assertion_DATA = ${SKY_SOURCES} SampleMakefile DISTCLEANFILES = SampleMakefile SkyPat-3.2.0/examples/assertion/main.cpp000066400000000000000000000050641465531052300202150ustar00rootroot00000000000000//===- main.cpp -----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // If you're like us, you'd like to look at some SkyPat sample code. The // examples/ folder has a numebr of well-commented samples show you how to // use SkyPat features. // // This sample shows how to write a simple performance test for a function, // using SkyPat framework. // //===----------------------------------------------------------------------===// // Step 1. Include necessary header files such that the stuff your test logic // needs is declared. #include "skypat/skypat.h" #include "my_case.h" // Step 2. Use the macro to define your performance test. // // SKYPAT macro has two parameters: the case name and the test name. // After using the macro, you must define your test logic between a pair of // braces. // // In SkyPat, test logics are grouped into `cases`. Every case has a bunch of // `tests`. This is how we organize the test codes. You should put logically // related tests into the same test case. // // Every test contains two parts: performance test and unit-test. // PERFORM macro is used to measure the performance of code within a test; // ASSERT macro compares the actual value to an expected value by using the // equals operator. skypat remembers the performance number of a test only if // all unit-tests in the test are passed. // // The names of cases and tests should be valid C++ identifiers. // // SkyPat does NOT guarantee that every tests you define is run exactly once. // In fact, SkyPat runs a test repeatedly for getting precise performance // numbers. Therefore, you should guarantee that in all runs the initial value // of a variable of a test is fixed. SKYPAT_F(MyCase, fibonacci_test) { int result = 0; // ASSERT are macros that resemble function calls. You test a class or function // by making assertions about its behavior. ASSERT_TRUE(0 != fibonacci(10)); } SKYPAT_F(MyCase, factorial_test) { ASSERT_FALSE(360 == factorial(5)); } // Step 3. Call RunAll() in main(). // // This runs all the tests you've defined, prints the result and // return 0 if succeed, or 1 otherwise. // // Did you notice that we didn't register any tests? The RunAll() // function magically knows about all the test we defined. Isn't it // convenient? int main(int argc, char* argv[]) { skypat::Test::Initialize(argc, argv); skypat::Test::RunAll(); } SkyPat-3.2.0/examples/assertion/my_case.cpp000066400000000000000000000016101465531052300207020ustar00rootroot00000000000000//===- my_case.cpp --------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using SkyPat performance testing framework. // // Author: Luba Tang //===----------------------------------------------------------------------===// #include "my_case.h" // Returns the Nth fibonacci number. For negative n, fibonacci(n) is defined to // be 1. int fibonacci(int n) { if (n <= 1) return 1; if (n == 2) return 2; return fibonacci(n-1) + fibonacci(n-2); } // Returns n! (the factorial of n). For negative n, n! is defined to be 1. int factorial(int n) { if (n <= 1) return 1; return n * factorial(n-1); } SkyPat-3.2.0/examples/assertion/my_case.h000066400000000000000000000014311465531052300203500ustar00rootroot00000000000000//===- my_case.h ----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using SkyPat performance testing framework. // // Author: Luba Tang //===----------------------------------------------------------------------===// #ifndef SKYPAT_SAMPLE1_MY_CASE_H #define SKYPAT_SAMPLE1_MY_CASE_H // Returns the Nth fibonacci number. For negative n, fibonacci(n) is defined to // be 1. int fibonacci(int n); // Returns n! (the factorial of n). For negative n, n! is defined to be 1. int factorial(int n); #endif SkyPat-3.2.0/examples/fail/000077500000000000000000000000001465531052300154645ustar00rootroot00000000000000SkyPat-3.2.0/examples/fail/Makefile.am000066400000000000000000000010431465531052300175160ustar00rootroot00000000000000SKYINCLUDES = -I${abs_top_srcdir}/include \ -I${abs_top_builddir}/include SKYLDFLAGS = -L$(abs_top_builddir)/lib SKY_SOURCES = main.cpp \ my_case.h \ my_case.cpp AM_CPPFLAGS = ${SKYINCLUDES} faildir = $(pkgdatadir)/examples/fail noinst_PROGRAMS = fail fail_LDFLAGS = ${SKYLDFLAGS} fail_LDADD = -lskypat dist_fail_SOURCES = ${SKY_SOURCES} include ../Example.mk $(eval $(call gen_sample_make, fail, ${SKY_SOURCES})) dist_fail_DATA = ${SKY_SOURCES} SampleMakefile DISTCLEANFILES = SampleMakefile SkyPat-3.2.0/examples/fail/main.cpp000066400000000000000000000060471465531052300171230ustar00rootroot00000000000000//===- main.cpp -----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // If you're like us, you'd like to look at some SkyPat sample code. The // examples/ folder has a numebr of well-commented samples show you how to // use SkyPat features. // // This sample shows how to write a simple performance test for a function, // using SkyPat framework. // //===----------------------------------------------------------------------===// // Step 1. Include necessary header files such that the stuff your test logic // needs is declared. #include "skypat/skypat.h" #include "my_case.h" // Step 2. Use the macro to define your performance test. // // SKYPAT macro has two parameters: the case name and the test name. // After using the macro, you must define your test logic between a pair of // braces. // // In SkyPat, test logics are grouped into `cases`. Every case has a bunch of // `tests`. This is how we organize the test codes. You should put logically // related tests into the same test case. // // Every test contains two parts: performance test and unit-test. // PERFORM macro is used to measure the performance of code within a test; // ASSERT macro compares the actual value to an expected value by using the // equals operator. skypat remembers the performance number of a test only if // all unit-tests in the test are passed. // // The names of cases and tests should be valid C++ identifiers. // // SkyPat does NOT guarantee that every tests you define is run exactly once. // In fact, SkyPat runs a test repeatedly for getting precise performance // numbers. Therefore, you should guarantee that in all runs the initial value // of a variable of a test is fixed. SKYPAT_F(MyCase, fibonacci_test) { int result = 0; // PERFORM macro is used to measure the performance of code within a test. The // code to be benchmark within a code block following this macro. PERFORM(skypat::CONTEXT_SWITCHES) { fibonacci(10); } // ASSERT are macros that resemble function calls. You test a class or function // by making assertions about its behavior. ASSERT_FALSE(0 != fibonacci(10)); } SKYPAT_F(MyCase, factorial_test) { ASSERT_TRUE(360 == factorial(5)); PERFORM(skypat::CONTEXT_SWITCHES) { factorial(5); } } SKYPAT_F(MyCase, factorial_test_2) { EXPECT_EQ(factorial(5), 360); EXPECT_NE(factorial(5), 120); EXPECT_LE(factorial(5), 119); EXPECT_LT(factorial(5), 119); EXPECT_GE(factorial(5), 121); EXPECT_GT(factorial(5), 121); } // Step 3. Call RunAll() in main(). // // This runs all the tests you've defined, prints the result and // return 0 if succeed, or 1 otherwise. // // Did you notice that we didn't register any tests? The RunAll() // function magically knows about all the test we defined. Isn't it // convenient? int main(int argc, char* argv[]) { skypat::Test::Initialize(argc, argv); skypat::Test::RunAll(); } SkyPat-3.2.0/examples/fail/my_case.cpp000066400000000000000000000016041465531052300176110ustar00rootroot00000000000000//===- my_case.cpp --------------------------------------------------------===// // // The pat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using "pat" performance testing framework. // // Author: Luba Tang //===----------------------------------------------------------------------===// #include "my_case.h" // Returns the Nth fibonacci number. For negative n, fibonacci(n) is defined to // be 1. int fibonacci(int n) { if (n <= 1) return 1; if (n == 2) return 2; return fibonacci(n-1) + fibonacci(n-2); } // Returns n! (the factorial of n). For negative n, n! is defined to be 1. int factorial(int n) { if (n <= 1) return 1; return n * factorial(n-1); } SkyPat-3.2.0/examples/fail/my_case.h000066400000000000000000000014171465531052300172600ustar00rootroot00000000000000//===- my_case.h ----------------------------------------------------------===// // // The pat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using "pat" performance testing framework. // // Author: Luba Tang //===----------------------------------------------------------------------===// #ifndef PAT_SAMPLE1_MY_CASE_H #define PAT_SAMPLE1_MY_CASE_H // Returns the Nth fibonacci number. For negative n, fibonacci(n) is defined to // be 1. int fibonacci(int n); // Returns n! (the factorial of n). For negative n, n! is defined to be 1. int factorial(int n); #endif SkyPat-3.2.0/examples/multi_assert/000077500000000000000000000000001465531052300172645ustar00rootroot00000000000000SkyPat-3.2.0/examples/multi_assert/Makefile.am000066400000000000000000000011431465531052300213170ustar00rootroot00000000000000SKYINCLUDES = -I${abs_top_srcdir}/include \ -I${abs_top_builddir}/include SKYLDFLAGS = -L$(abs_top_builddir)/lib SKY_SOURCES = main.cpp \ my_case.h \ my_case.cpp AM_CPPFLAGS = ${SKYINCLUDES} multi_assertdir = $(pkgdatadir)/examples/multi_assert noinst_PROGRAMS = multi_assert multi_assert_LDFLAGS = ${SKYLDFLAGS} multi_assert_LDADD = -lskypat dist_multi_assert_SOURCES = ${SKY_SOURCES} include ../Example.mk $(eval $(call gen_sample_make, multi_assert, ${SKY_SOURCES})) dist_multi_assert_DATA = ${SKY_SOURCES} SampleMakefile DISTCLEANFILES = SampleMakefile SkyPat-3.2.0/examples/multi_assert/main.cpp000066400000000000000000000051651465531052300207230ustar00rootroot00000000000000//===- main.cpp -----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // If you're like us, you'd like to look at some SkyPat sample code. The // examples/ folder has a numebr of well-commented samples show you how to // use SkyPat features. // // This sample shows how to write a simple performance test for a function, // using SkyPat framework. // //===----------------------------------------------------------------------===// // Step 1. Include necessary header files such that the stuff your test logic // needs is declared. #include "skypat/skypat.h" #include "my_case.h" // Step 2. Use the macro to define your performance test. // // SKYPAT macro has two parameters: the case name and the test name. // After using the macro, you must define your test logic between a pair of // braces. // // In SkyPat, test logics are grouped into `cases`. Every case has a bunch of // `tests`. This is how we organize the test codes. You should put logically // related tests into the same test case. // // Every test contains two parts: performance test and unit-test. // PERFORM macro is used to measure the performance of code within a test; // ASSERT macro compares the actual value to an expected value by using the // equals operator. skypat remembers the performance number of a test only if // all unit-tests in the test are passed. // // The names of cases and tests should be valid C++ identifiers. // // SkyPat does NOT guarantee that every tests you define is run exactly once. // In fact, SkyPat runs a test repeatedly for getting precise performance // numbers. Therefore, you should guarantee that in all runs the initial value // of a variable of a test is fixed. SKYPAT_F(MyCase, fibonacci_test) { int result = 0; // ASSERT are macros that resemble function calls. You test a class or function // by making assertions about its behavior. ASSERT_TRUE(0 != fibonacci(10)); ASSERT_TRUE(2 == fibonacci(10)); ASSERT_TRUE(0 != fibonacci(10)); } SKYPAT_F(MyCase, factorial_test) { ASSERT_FALSE(360 == factorial(5)); } // Step 3. Call RunAll() in main(). // // This runs all the tests you've defined, prints the result and // return 0 if succeed, or 1 otherwise. // // Did you notice that we didn't register any tests? The RunAll() // function magically knows about all the test we defined. Isn't it // convenient? int main(int argc, char* argv[]) { skypat::Test::Initialize(argc, argv); skypat::Test::RunAll(); } SkyPat-3.2.0/examples/multi_assert/my_case.cpp000066400000000000000000000016071465531052300214140ustar00rootroot00000000000000//===- my_case.cpp --------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using SkyPat performance testing framework. // // Author: Luba Tang //===----------------------------------------------------------------------===// #include "my_case.h" // Returns the Nth fibonacci number. For negative n, fibonacci(n) is defined to // be 1. int fibonacci(int n) { if (n <= 1) return 1; if (n == 2) return 2; return fibonacci(n-1) + fibonacci(n-2); } // Returns n! (the factorial of n). For negative n, n! is defined to be 1. int factorial(int n) { if (n <= 1) return 1; return n * factorial(n-1); } SkyPat-3.2.0/examples/multi_assert/my_case.h000066400000000000000000000014301465531052300210530ustar00rootroot00000000000000//===- my_case.h ----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using SkyPat performance testing framework. // // Author: Luba Tang //===----------------------------------------------------------------------===// #ifndef SKYPAT_SAMPLE1_MY_CASE_H #define SKYPAT_SAMPLE1_MY_CASE_H // Returns the Nth fibonacci number. For negative n, fibonacci(n) is defined to // be 1. int fibonacci(int n); // Returns n! (the factorial of n). For negative n, n! is defined to be 1. int factorial(int n); #endif SkyPat-3.2.0/examples/multi_case/000077500000000000000000000000001465531052300166765ustar00rootroot00000000000000SkyPat-3.2.0/examples/multi_case/Makefile.am000066400000000000000000000011231465531052300207270ustar00rootroot00000000000000SKYINCLUDES = -I${abs_top_srcdir}/include \ -I${abs_top_builddir}/include SKYLDFLAGS = -L$(abs_top_builddir)/lib SKY_SOURCES = main.cpp \ my_case.h \ my_case.cpp AM_CPPFLAGS = ${SKYINCLUDES} multi_casedir = $(pkgdatadir)/examples/multi_case noinst_PROGRAMS = multi_case multi_case_LDFLAGS = ${SKYLDFLAGS} multi_case_LDADD = -lskypat dist_multi_case_SOURCES = ${SKY_SOURCES} include ../Example.mk $(eval $(call gen_sample_make, multi_case, ${SKY_SOURCES})) dist_multi_case_DATA = ${SKY_SOURCES} SampleMakefile DISTCLEANFILES = SampleMakefile SkyPat-3.2.0/examples/multi_case/main.cpp000066400000000000000000000061501465531052300203300ustar00rootroot00000000000000//===- main.cpp -----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // If you're like us, you'd like to look at some SkyPat sample code. The // examples/ folder has a numebr of well-commented samples show you how to // use SkyPat features. // // This sample shows how to write a simple performance test for a function, // using SkyPat framework. // //===----------------------------------------------------------------------===// // Step 1. Include necessary header files such that the stuff your test logic // needs is declared. #include "skypat/skypat.h" #include "my_case.h" // Step 2. Use the macro to define your performance test. // // SKYPAT macro has two parameters: the case name and the test name. // After using the macro, you must define your test logic between a pair of // braces. // // In SkyPat, test logics are grouped into `cases`. Every case has a bunch of // `tests`. This is how we organize the test codes. You should put logically // related tests into the same test case. // // Every test contains two parts: performance test and unit-test. // PERFORM macro is used to measure the performance of code within a test; // ASSERT macro compares the actual value to an expected value by using the // equals operator. skypat remembers the performance number of a test only if // all unit-tests in the test are passed. // // The names of cases and tests should be valid C++ identifiers. // // SkyPat does NOT guarantee that every tests you define is run exactly once. // In fact, SkyPat runs a test repeatedly for getting precise performance // numbers. Therefore, you should guarantee that in all runs the initial value // of a variable of a test is fixed. SKYPAT_F(Fibonacci, fibonacci_result) { int result = 0; PERFORM(skypat::CONTEXT_SWITCHES) { result = fibonacci(5); } EXPECT_TRUE(result == 8); PERFORM(skypat::CONTEXT_SWITCHES) { result = fibonacci(10); } EXPECT_TRUE(result == 89); } SKYPAT_F(Fibonacci, fibonacci_special_case) { int result = 0; PERFORM(skypat::CONTEXT_SWITCHES) { result = fibonacci(-1); } EXPECT_TRUE(result == 1); } SKYPAT_F(Factorial, factorial_result) { int result = 0; PERFORM(skypat::CONTEXT_SWITCHES) { result = factorial(5); } EXPECT_TRUE(result == 120); PERFORM(skypat::CONTEXT_SWITCHES) { result = factorial(10); } EXPECT_TRUE(result == 3628800); } SKYPAT_F(Factorial, factorial_special_case) { int result = 0; PERFORM(skypat::CONTEXT_SWITCHES) { result = factorial(-1); } EXPECT_TRUE(result == 1); } // Step 3. Call RunAll() in main(). // // This runs all the tests you've defined, prints the result and // return 0 if succeed, or 1 otherwise. // // Did you notice that we didn't register any tests? The RunAll() // function magically knows about all the test we defined. Isn't it // convenient? int main(int argc, char* argv[]) { skypat::Test::Initialize(argc, argv); skypat::Test::RunAll(); } SkyPat-3.2.0/examples/multi_case/my_case.cpp000066400000000000000000000016101465531052300210200ustar00rootroot00000000000000//===- my_case.cpp --------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using SkyPat performance testing framework. // // Author: Luba Tang //===----------------------------------------------------------------------===// #include "my_case.h" // Returns the Nth fibonacci number. For negative n, fibonacci(n) is defined to // be 1. int fibonacci(int n) { if (n <= 1) return 1; if (n == 2) return 2; return fibonacci(n-1) + fibonacci(n-2); } // Returns n! (the factorial of n). For negative n, n! is defined to be 1. int factorial(int n) { if (n <= 1) return 1; return n * factorial(n-1); } SkyPat-3.2.0/examples/multi_case/my_case.h000066400000000000000000000014251465531052300204710ustar00rootroot00000000000000//===- my_case.h ----------------------------------------------------------===// // // The pat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using "pat" performance testing framework. // // Author: Luba Tang //===----------------------------------------------------------------------===// #ifndef SKYPAT_SAMPLE1_MY_CASE_H #define SKYPAT_SAMPLE1_MY_CASE_H // Returns the Nth fibonacci number. For negative n, fibonacci(n) is defined to // be 1. int fibonacci(int n); // Returns n! (the factorial of n). For negative n, n! is defined to be 1. int factorial(int n); #endif SkyPat-3.2.0/examples/multi_expect/000077500000000000000000000000001465531052300172535ustar00rootroot00000000000000SkyPat-3.2.0/examples/multi_expect/Makefile.am000066400000000000000000000011431465531052300213060ustar00rootroot00000000000000SKYINCLUDES = -I${abs_top_srcdir}/include \ -I${abs_top_builddir}/include SKYLDFLAGS = -L$(abs_top_builddir)/lib SKY_SOURCES = main.cpp \ my_case.h \ my_case.cpp AM_CPPFLAGS = ${SKYINCLUDES} multi_expectdir = $(pkgdatadir)/examples/multi_expect noinst_PROGRAMS = multi_expect multi_expect_LDFLAGS = ${SKYLDFLAGS} multi_expect_LDADD = -lskypat dist_multi_expect_SOURCES = ${SKY_SOURCES} include ../Example.mk $(eval $(call gen_sample_make, multi_expect, ${SKY_SOURCES})) dist_multi_expect_DATA = ${SKY_SOURCES} SampleMakefile DISTCLEANFILES = SampleMakefile SkyPat-3.2.0/examples/multi_expect/main.cpp000066400000000000000000000052331465531052300207060ustar00rootroot00000000000000//===- main.cpp -----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // If you're like us, you'd like to look at some SkyPat sample code. The // examples/ folder has a numebr of well-commented samples show you how to // use SkyPat features. // // This sample shows how to write a simple performance test for a function, // using SkyPat framework. // //===----------------------------------------------------------------------===// // Step 1. Include necessary header files such that the stuff your test logic // needs is declared. #include "skypat/skypat.h" #include "my_case.h" // Step 2. Use the macro to define your performance test. // // SKYPAT macro has two parameters: the case name and the test name. // After using the macro, you must define your test logic between a pair of // braces. // // In SkyPat, test logics are grouped into `cases`. Every case has a bunch of // `tests`. This is how we organize the test codes. You should put logically // related tests into the same test case. // // Every test contains two parts: performance test and unit-test. // PERFORM macro is used to measure the performance of code within a test; // EXPECT macro compares the actual value to an expected value by using the // equals operator. skypat remembers the performance number of a test only if // all unit-tests in the test are passed. // // The names of cases and tests should be valid C++ identifiers. // // SkyPat does NOT guarantee that every tests you define is run exactly once. // In fact, SkyPat runs a test repeatedly for getting precise performance // numbers. Therefore, you should guarantee that in all runs the initial value // of a variable of a test is fixed. SKYPAT_F(MyCase, fibonacci_test) { int result = 0; // EXPECT are macros that resemble function calls. You test a class or function // by making assertions about its behavior. EXPECT_TRUE(0 != fibonacci(10)); EXPECT_TRUE(2 == fibonacci(10)); EXPECT_TRUE(10 == fibonacci(10)); EXPECT_FALSE(10 != fibonacci(10)); } SKYPAT_F(MyCase, factorial_test) { EXPECT_FALSE(360 == factorial(5)); } // Step 3. Call RunAll() in main(). // // This runs all the tests you've defined, prints the result and // return 0 if succeed, or 1 otherwise. // // Did you notice that we didn't register any tests? The RunAll() // function magically knows about all the test we defined. Isn't it // convenient? int main(int argc, char* argv[]) { skypat::Test::Initialize(argc, argv); skypat::Test::RunAll(); } SkyPat-3.2.0/examples/multi_expect/my_case.cpp000066400000000000000000000016101465531052300213750ustar00rootroot00000000000000//===- my_case.cpp --------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using SkyPat performance testing framework. // // Author: Luba Tang //===----------------------------------------------------------------------===// #include "my_case.h" // Returns the Nth fibonacci number. For negative n, fibonacci(n) is defined to // be 1. int fibonacci(int n) { if (n <= 1) return 1; if (n == 2) return 2; return fibonacci(n-1) + fibonacci(n-2); } // Returns n! (the factorial of n). For negative n, n! is defined to be 1. int factorial(int n) { if (n <= 1) return 1; return n * factorial(n-1); } SkyPat-3.2.0/examples/multi_expect/my_case.h000066400000000000000000000014311465531052300210430ustar00rootroot00000000000000//===- my_case.h ----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using SkyPat performance testing framework. // // Author: Luba Tang //===----------------------------------------------------------------------===// #ifndef SKYPAT_SAMPLE1_MY_CASE_H #define SKYPAT_SAMPLE1_MY_CASE_H // Returns the Nth fibonacci number. For negative n, fibonacci(n) is defined to // be 1. int fibonacci(int n); // Returns n! (the factorial of n). For negative n, n! is defined to be 1. int factorial(int n); #endif SkyPat-3.2.0/examples/performance/000077500000000000000000000000001465531052300170525ustar00rootroot00000000000000SkyPat-3.2.0/examples/performance/Makefile.am000066400000000000000000000011331465531052300211040ustar00rootroot00000000000000SKYINCLUDES = -I${abs_top_srcdir}/include \ -I${abs_top_builddir}/include SKYLDFLAGS = -L$(abs_top_builddir)/lib SKY_SOURCES = main.cpp \ my_case.h \ my_case.cpp AM_CPPFLAGS = ${SKYINCLUDES} performancedir = $(pkgdatadir)/examples/performance noinst_PROGRAMS = performance performance_LDFLAGS = ${SKYLDFLAGS} performance_LDADD = -lskypat dist_performance_SOURCES = ${SKY_SOURCES} include ../Example.mk $(eval $(call gen_sample_make, performance, ${SKY_SOURCES})) dist_performance_DATA = ${SKY_SOURCES} SampleMakefile DISTCLEANFILES = SampleMakefile SkyPat-3.2.0/examples/performance/main.cpp000066400000000000000000000057641465531052300205160ustar00rootroot00000000000000//===- main.cpp -----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // If you're like us, you'd like to look at some SkyPat sample code. The // examples/ folder has a numebr of well-commented samples show you how to // use SkyPat features. // // This sample shows how to write a simple performance test for a function, // using SkyPat framework. // //===----------------------------------------------------------------------===// // Step 1. Include necessary header files such that the stuff your test logic // needs is declared. #include #include "skypat/skypat.h" #include "my_case.h" // Step 2. Use the macro to define your performance test. // // SKYPAT macro has two parameters: the case name and the test name. // After using the macro, you must define your test logic between a pair of // braces. // // In SkyPat, test logics are grouped into `cases`. Every case has a bunch of // `tests`. This is how we organize the test codes. You should put logically // related tests into the same test case. // // Every test contains two parts: performance test and unit-test. // PERFORM macro is used to measure the performance of code within a test; // ASSERT macro compares the actual value to an expected value by using the // equals operator. skypat remembers the performance number of a test only if // all unit-tests in the test are passed. // // The names of cases and tests should be valid C++ identifiers. // // SkyPat does NOT guarantee that every tests you define is run exactly once. // In fact, SkyPat runs a test repeatedly for getting precise performance // numbers. Therefore, you should guarantee that in all runs the initial value // of a variable of a test is fixed. SKYPAT_F(MyCase, fibonacci_test) { // PERFORM macro is used to measure the performance of code within a test. The // code to be benchmark within a code block following this macro. PERFORM(skypat::CONTEXT_SWITCHES) { fibonacci(10); } PERFORM(skypat::CPU_CLOCK) { fibonacci(10); } PERFORM(skypat::TASK_CLOCK) { fibonacci(10); } PERFORM(skypat::CPU_CYCLES) { fibonacci(10); } PERFORM(skypat::INSTRUCTIONS) { fibonacci(10); } } SKYPAT_F(MyCase, factorial_test) { PERFORM(skypat::CONTEXT_SWITCHES) { factorial(5); usleep(1); factorial(5); usleep(1); factorial(5); } PERFORM(skypat::CONTEXT_SWITCHES) { factorial(100); usleep(1); factorial(5); } } // Step 3. Call RunAll() in main(). // // This runs all the tests you've defined, prints the result and // return 0 if succeed, or 1 otherwise. // // Did you notice that we didn't register any tests? The RunAll() // function magically knows about all the test we defined. Isn't it // convenient? int main(int argc, char* argv[]) { skypat::Test::Initialize(argc, argv); skypat::Test::RunAll(); } SkyPat-3.2.0/examples/performance/my_case.cpp000066400000000000000000000016101465531052300211740ustar00rootroot00000000000000//===- my_case.cpp --------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using SkyPat performance testing framework. // // Author: Luba Tang //===----------------------------------------------------------------------===// #include "my_case.h" // Returns the Nth fibonacci number. For negative n, fibonacci(n) is defined to // be 1. int fibonacci(int n) { if (n <= 1) return 1; if (n == 2) return 2; return fibonacci(n-1) + fibonacci(n-2); } // Returns n! (the factorial of n). For negative n, n! is defined to be 1. int factorial(int n) { if (n <= 1) return 1; return n * factorial(n-1); } SkyPat-3.2.0/examples/performance/my_case.h000066400000000000000000000014311465531052300206420ustar00rootroot00000000000000//===- my_case.h ----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using SkyPat performance testing framework. // // Author: Luba Tang //===----------------------------------------------------------------------===// #ifndef SKYPAT_SAMPLE1_MY_CASE_H #define SKYPAT_SAMPLE1_MY_CASE_H // Returns the Nth fibonacci number. For negative n, fibonacci(n) is defined to // be 1. int fibonacci(int n); // Returns n! (the factorial of n). For negative n, n! is defined to be 1. int factorial(int n); #endif SkyPat-3.2.0/examples/skypat_c/000077500000000000000000000000001465531052300163665ustar00rootroot00000000000000SkyPat-3.2.0/examples/skypat_c/Makefile.am000066400000000000000000000011031465531052300204150ustar00rootroot00000000000000SKYINCLUDES = -I${abs_top_srcdir}/include \ -I${abs_top_builddir}/include SKYLDFLAGS = -L$(abs_top_builddir)/lib SKY_SOURCES = main.cpp \ my_case.h \ my_case.cpp AM_CPPFLAGS = ${SKYINCLUDES} skypat_cdir = $(pkgdatadir)/examples/skypat_c noinst_PROGRAMS = skypat_c skypat_c_LDFLAGS = ${SKYLDFLAGS} skypat_c_LDADD = -lskypat dist_skypat_c_SOURCES = ${SKY_SOURCES} include ../Example.mk $(eval $(call gen_sample_make, skypat_c, ${SKY_SOURCES})) dist_skypat_c_DATA = ${SKY_SOURCES} SampleMakefile DISTCLEANFILES = SampleMakefile SkyPat-3.2.0/examples/skypat_c/main.cpp000066400000000000000000000070321465531052300200200ustar00rootroot00000000000000//===- main.cpp -----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // If you're like us, you'd like to look at some SkyPat sample code. The // examples/ folder has a numebr of well-commented samples show you how to // use SkyPat features. // // This sample shows how to write a simple performance test for a function, // using SkyPat framework. // //===----------------------------------------------------------------------===// // Step 1. Include necessary header files such that the stuff your test logic // needs is declared. #include "skypat/skypat.h" #include "my_case.h" // Step 2. Use the macro to define your performance test. // // SKYPAT macro has two parameters: the case name and the test name. // After using the macro, you must define your test logic between a pair of // braces. // // In SkyPat, test logics are grouped into `cases`. Every case has a bunch of // `tests`. This is how we organize the test codes. You should put logically // related tests into the same test case. // // Every test contains two parts: performance test and unit-test. // PERFORM macro is used to measure the performance of code within a test; // ASSERT macro compares the actual value to an expected value by using the // equals operator. skypat remembers the performance number of a test only if // all unit-tests in the test are passed. // // The names of cases and tests should be valid C++ identifiers. // // SkyPat does NOT guarantee that every tests you define is run exactly once. // In fact, SkyPat runs a test repeatedly for getting precise performance // numbers. Therefore, you should guarantee that in all runs the initial value // of a variable of a test is fixed. class MyCase : public skypat::Test { public: // create a turret for all test. void SetUp() { m_turret = TurretFactory::CreateTurret(); } // clear up the memory. void TearDown() { TurretFactory::DestoryTurret(m_turret); } Turret * getTurret() { return m_turret; }; private: Turret * m_turret; }; // test the default status of turret SKYPAT_C(MyCase, test_turret_is_turn_by_default) { Turret * turret = this->getTurret(); EXPECT_TRUE( true==turret->isOn() ); } // test the turn on turn of functions of turret SKYPAT_C(MyCase, test_turret_can_be_turn_off) { Turret * turret = this->getTurret(); turret->turnOff(); EXPECT_TRUE( false==turret->isOn() ); } // test the turn on turn of functions of turret SKYPAT_C(MyCase, test_turret_can_fire_iff_turn_on) { Turret * turret = this->getTurret(); turret->turnOff(); EXPECT_TRUE( false==turret->fire() ); turret->turnOn(); EXPECT_TRUE( true==turret->fire() ); } // Performance Test SKYPAT_C(MyCase, performance_turret_fire) { // Make sure the turret is On. Turret * turret = this->getTurret(); turret->turnOn(); ASSERT_TRUE( turret->isOn() ); // Start performance test PERFORM(skypat::CONTEXT_SWITCHES) { turret->fire(); } } // Step 3. Call RunAll() in main(). // // This runs all the tests you've defined, prints the result and // return 0 if succeed, or 1 otherwise. // // Did you notice that we didn't register any tests? The RunAll() // function magically knows about all the test we defined. Isn't it // convenient? int main(int argc, char* argv[]) { skypat::Test::Initialize(argc, argv); skypat::Test::RunAll(); } SkyPat-3.2.0/examples/skypat_c/my_case.cpp000066400000000000000000000023671465531052300205220ustar00rootroot00000000000000//===- my_case.cpp --------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using SkyPat performance testing framework. // // Author: Ying-Chieh Chen //===----------------------------------------------------------------------===// #include "my_case.h" #ifdef __linux__ #include #endif #if defined(_WIN32) || defined(_WIN64) #inlcude #endif // Create a Turret Turret * TurretFactory::CreateTurret() { Turret * t = new Turret(); t->turnOn(); return t; } // Delete a Turret void TurretFactory::DestoryTurret(Turret *pTurret) { delete pTurret; } // Fire if On and return true, else return false. // (using sleep to simulate fire time cost.) bool Turret::fire() { if(m_status) { this->sleepMs(5); } return m_status; } // sleep function. void Turret::sleepMs(int sleepMs) { #ifdef __linux__ usleep(sleepMs * 1000); // usleep takes sleep time in us #endif #if defined(_WIN32) || defined(_WIN64) Sleep(sleepMs); #endif } SkyPat-3.2.0/examples/skypat_c/my_case.h000066400000000000000000000022241465531052300201570ustar00rootroot00000000000000//===- my_case.h ----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using SkyPat performance testing framework. // // Author: Ying-Chieh Chen //===----------------------------------------------------------------------===// #ifndef SKYPAT_SAMPLE2_MY_CASE_H #define SKYPAT_SAMPLE2_MY_CASE_H class Turret; // A factory which can create turret. class TurretFactory { public: TurretFactory() {} ~TurretFactory(){} static Turret * CreateTurret(); static void DestoryTurret(Turret *pTurret); }; // A Turret class which can be turn on/off class Turret { public: Turret() {} ~Turret() {} bool isOn() { return m_status; } void turnOn() { m_status=true; } void turnOff(){ m_status=false; } // Fire if On and return true, else return false. bool fire(); private: void sleepMs(int sleepMs); private: bool m_status; }; #endif SkyPat-3.2.0/examples/smoke/000077500000000000000000000000001465531052300156675ustar00rootroot00000000000000SkyPat-3.2.0/examples/smoke/Makefile.am000066400000000000000000000010531465531052300177220ustar00rootroot00000000000000SKYINCLUDES = -I${abs_top_srcdir}/include \ -I${abs_top_builddir}/include SKYLDFLAGS = -L$(abs_top_builddir)/lib SKY_SOURCES = main.cpp \ my_case.h \ my_case.cpp AM_CPPFLAGS = ${SKYINCLUDES} smokedir = $(pkgdatadir)/examples/smoke noinst_PROGRAMS = smoke smoke_LDFLAGS = ${SKYLDFLAGS} smoke_LDADD = -lskypat dist_smoke_SOURCES = ${SKY_SOURCES} include ../Example.mk $(eval $(call gen_sample_make, smoke, ${SKY_SOURCES})) dist_smoke_DATA = ${SKY_SOURCES} SampleMakefile DISTCLEANFILES = SampleMakefile SkyPat-3.2.0/examples/smoke/main.cpp000066400000000000000000000054751465531052300173320ustar00rootroot00000000000000//===- main.cpp -----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // If you're like us, you'd like to look at some SkyPat sample code. The // examples/ folder has a numebr of well-commented samples show you how to // use SkyPat features. // // This sample shows how to write a simple performance test for a function, // using SkyPat framework. // //===----------------------------------------------------------------------===// // Step 1. Include necessary header files such that the stuff your test logic // needs is declared. #include "skypat/skypat.h" #include "my_case.h" // Step 2. Use the macro to define your performance test. // // SKYPAT macro has two parameters: the case name and the test name. // After using the macro, you must define your test logic between a pair of // braces. // // In SkyPat, test logics are grouped into `cases`. Every case has a bunch of // `tests`. This is how we organize the test codes. You should put logically // related tests into the same test case. // // Every test contains two parts: performance test and unit-test. // PERFORM macro is used to measure the performance of code within a test; // ASSERT macro compares the actual value to an expected value by using the // equals operator. skypat remembers the performance number of a test only if // all unit-tests in the test are passed. // // The names of cases and tests should be valid C++ identifiers. // // SkyPat does NOT guarantee that every tests you define is run exactly once. // In fact, SkyPat runs a test repeatedly for getting precise performance // numbers. Therefore, you should guarantee that in all runs the initial value // of a variable of a test is fixed. SKYPAT_F(MyCase, fibonacci_test) { int result = 0; // PERFORM macro is used to measure the performance of code within a test. The // code to be benchmark within a code block following this macro. PERFORM(skypat::CONTEXT_SWITCHES) { fibonacci(10); } // ASSERT are macros that resemble function calls. You test a class or function // by making assertions about its behavior. ASSERT_TRUE(0 != fibonacci(10)); } SKYPAT_F(MyCase, factorial_test) { ASSERT_TRUE(120 == factorial(5)); PERFORM(skypat::CONTEXT_SWITCHES) { factorial(5); } } // Step 3. Call RunAll() in main(). // // This runs all the tests you've defined, prints the result and // return 0 if succeed, or 1 otherwise. // // Did you notice that we didn't register any tests? The RunAll() // function magically knows about all the test we defined. Isn't it // convenient? int main(int argc, char* argv[]) { skypat::Test::Initialize(argc, argv); skypat::Test::RunAll(); } SkyPat-3.2.0/examples/smoke/my_case.cpp000066400000000000000000000016101465531052300200110ustar00rootroot00000000000000//===- my_case.cpp --------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using SkyPat performance testing framework. // // Author: Luba Tang //===----------------------------------------------------------------------===// #include "my_case.h" // Returns the Nth fibonacci number. For negative n, fibonacci(n) is defined to // be 1. int fibonacci(int n) { if (n <= 1) return 1; if (n == 2) return 2; return fibonacci(n-1) + fibonacci(n-2); } // Returns n! (the factorial of n). For negative n, n! is defined to be 1. int factorial(int n) { if (n <= 1) return 1; return n * factorial(n-1); } SkyPat-3.2.0/examples/smoke/my_case.h000066400000000000000000000014311465531052300174570ustar00rootroot00000000000000//===- my_case.h ----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // A sample program demonstrating using SkyPat performance testing framework. // // Author: Luba Tang //===----------------------------------------------------------------------===// #ifndef SKYPAT_SAMPLE1_MY_CASE_H #define SKYPAT_SAMPLE1_MY_CASE_H // Returns the Nth fibonacci number. For negative n, fibonacci(n) is defined to // be 1. int fibonacci(int n); // Returns n! (the factorial of n). For negative n, n! is defined to be 1. int factorial(int n); #endif SkyPat-3.2.0/examples/thread/000077500000000000000000000000001465531052300160205ustar00rootroot00000000000000SkyPat-3.2.0/examples/thread/Makefile.am000066400000000000000000000010371465531052300200550ustar00rootroot00000000000000SKYINCLUDES = -I${abs_top_srcdir}/include \ -I${abs_top_builddir}/include SKYLDFLAGS = -L$(abs_top_builddir)/lib SKY_SOURCES = main.cpp \ ThreadTest.h AM_CPPFLAGS = ${SKYINCLUDES} -fno-rtti threaddir = $(pkgdatadir)/examples/thread noinst_PROGRAMS = thread thread_LDFLAGS = ${SKYLDFLAGS} thread_LDADD = -lskypat thread_SOURCES = ${SKY_SOURCES} include ../Example.mk $(eval $(call gen_sample_make, thread, ${SKY_SOURCES})) dist_thread_DATA = ${SKY_SOURCES} SampleMakefile DISTCLEANFILES = SampleMakefile SkyPat-3.2.0/examples/thread/ThreadTest.h000066400000000000000000000021751465531052300202450ustar00rootroot00000000000000//===- ThreadTest.h -----------------------------------------------------===// // // The SkyPat team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include #include using namespace skypat; class Counter { public: static Counter* self() { static Counter instance; return &instance; } unsigned int value() const { ScopedLock locker(m_Mutex); return m_Value; } void increase() { ScopedLock locker(m_Mutex); ++m_Value; } private: unsigned int m_Value; mutable Mutex m_Mutex; }; class WriterThread : public Thread { public: void run() { while(20 != Counter::self()->value()) Counter::self()->increase(); } }; class MonitorThread : public Thread { public: void run() { while (20 != Counter::self()->value()) ; get_ten = true; } bool getTen() const { return get_ten; } public: static bool get_ten; }; bool MonitorThread::get_ten = false; SkyPat-3.2.0/examples/thread/main.cpp000066400000000000000000000050331465531052300174510ustar00rootroot00000000000000//===- main.cpp -----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // // If you're like us, you'd like to look at some SkyPat sample code. The // examples/ folder has a numebr of well-commented samples show you how to // use SkyPat features. // // This sample shows how to write a simple performance test for a function, // using SkyPat framework. // //===----------------------------------------------------------------------===// // Step 1. Include necessary header files such that the stuff your test logic // needs is declared. #include "skypat/skypat.h" #include "ThreadTest.h" // Step 2. Use the macro to define your performance test. // // SKYPAT macro has two parameters: the case name and the test name. // After using the macro, you must define your test logic between a pair of // braces. // // In SkyPat, test logics are grouped into `cases`. Every case has a bunch of // `tests`. This is how we organize the test codes. You should put logically // related tests into the same test case. // // Every test contains two parts: performance test and unit-test. // PERFORM macro is used to measure the performance of code within a test; // ASSERT macro compares the actual value to an expected value by using the // equals operator. skypat remembers the performance number of a test only if // all unit-tests in the test are passed. // // The names of cases and tests should be valid C++ identifiers. // // SkyPat does NOT guarantee that every tests you define is run exactly once. // In fact, SkyPat runs a test repeatedly for getting precise performance // numbers. Therefore, you should guarantee that in all runs the initial value // of a variable of a test is fixed. SKYPAT_F(ThreadTest, monitor_test) { WriterThread* t1 = new WriterThread(); MonitorThread* t2 = new MonitorThread(); t1->start(); t2->start(); t1->join(); t2->join(); ASSERT_EQ(Counter::self()->value(), 20); ASSERT_TRUE(MonitorThread::get_ten); } // Step 3. Call RunAll() in main(). // // This runs all the tests you've defined, prints the result and // return 0 if succeed, or 1 otherwise. // // Did you notice that we didn't register any tests? The RunAll() // function magically knows about all the test we defined. Isn't it // convenient? int main(int argc, char* argv[]) { skypat::Test::Initialize(argc, argv); skypat::Test::RunAll(); } SkyPat-3.2.0/include/000077500000000000000000000000001465531052300143565ustar00rootroot00000000000000SkyPat-3.2.0/include/Makefile.am000066400000000000000000000011401465531052300164060ustar00rootroot00000000000000nobase_include_HEADERS = skypat/skypat.h \ skypat/ADT/Color.h \ skypat/ADT/TypeTraits.h \ skypat/ADT/Uncopyable.h \ skypat/Listeners/PrettyResultPrinter.h \ skypat/Listeners/CSVResultPrinter.h \ skypat/SkypatNamespace.h \ skypat/Support/IOSFwd.h \ skypat/Support/ManagedStatic.h \ skypat/Support/OStrStream.h \ skypat/Support/OStrStream.tcc \ skypat/Support/Path.h \ skypat/Support/Timer.h \ skypat/Thread/Mutex.h \ skypat/Thread/MutexImpl.h \ skypat/Thread/Thread.h \ skypat/Thread/ThreadImpl.h SkyPat-3.2.0/include/skypat/000077500000000000000000000000001465531052300156715ustar00rootroot00000000000000SkyPat-3.2.0/include/skypat/ADT/000077500000000000000000000000001465531052300163015ustar00rootroot00000000000000SkyPat-3.2.0/include/skypat/ADT/Color.h000066400000000000000000000022521465531052300175310ustar00rootroot00000000000000//===- Color.h --------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_SUPPORT_COLOR_H #define SKYPAT_SUPPORT_COLOR_H #include #include namespace skypat { /** \class Color * \brief Color is a std::ostream manipulator for changing the color. */ class Color { public: // color order matches ANSI escape sequence, don't change enum kColor { BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET }; enum kType { NORMAL, BOLD, BACKGROUND }; public: Color(kColor pColor = BLACK, kType pType = NORMAL); static Color Bold(kColor pColor); static Color BackGround(kColor pColor); void setColor(std::ostream& pOS); private: kColor m_Color : 24; kType m_Type : 8; }; } // namespace of skypat namespace std { ostream& operator<<(ostream& pOS, skypat::Color pColor); ostream& operator<<(ostream& pOS, skypat::Color::kColor pColor); } // namespace of std #endif SkyPat-3.2.0/include/skypat/ADT/TypeTraits.h000066400000000000000000000042551465531052300205700ustar00rootroot00000000000000//===- TypeTraits.h -------------------------------------------------------===// // // The SkyPat team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_TYPE_TRAITS_H #define SKYPAT_TYPE_TRAITS_H #include namespace skypat { typedef void * HANDLE; template struct NonConstTraits; template struct ConstTraits { typedef const DataType value_type; typedef const DataType* pointer; typedef const DataType& reference; typedef size_t size_type; typedef ConstTraits const_traits; typedef NonConstTraits nonconst_traits; template struct rebind { typedef ConstTraits other; }; }; template struct NonConstTraits { typedef DataType value_type; typedef DataType* pointer; typedef DataType& reference; typedef size_t size_type; typedef ConstTraits const_traits; typedef NonConstTraits nonconst_traits; template struct rebind { typedef NonConstTraits other; }; }; template struct ConstIteratorTraits { typedef DataType value_type; typedef const DataType* pointer; typedef const DataType& reference; typedef size_t size_type; typedef ConstTraits const_traits; typedef NonConstTraits nonconst_traits; typedef typename DataType::const_iterator iterator; }; template struct NonConstIteratorTraits { typedef DataType value_type; typedef DataType* pointer; typedef DataType& reference; typedef size_t size_type; typedef ConstTraits const_traits; typedef NonConstTraits nonconst_traits; typedef typename DataType::iterator iterator; }; } // namespace of skypat #endif SkyPat-3.2.0/include/skypat/ADT/Uncopyable.h000066400000000000000000000013261465531052300205550ustar00rootroot00000000000000//===- Uncopyable.h -------------------------------------------------------===// // // The SkyPat team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_ADT_UNCOPYABLE_H #define SKYPAT_ADT_UNCOPYABLE_H namespace skypat { /** \class Uncopyable * \brief Uncopyable provides the base class to forbit copy operations. * */ class Uncopyable { protected: Uncopyable() { } ~Uncopyable() { } private: Uncopyable(const Uncopyable&); /// NOT TO IMPLEMENT Uncopyable& operator=(const Uncopyable&); /// NOT TO IMPLEMENT }; } // namespace of skypat #endif SkyPat-3.2.0/include/skypat/Config/000077500000000000000000000000001465531052300170765ustar00rootroot00000000000000SkyPat-3.2.0/include/skypat/Config/Config.h.in000066400000000000000000000107261465531052300210670ustar00rootroot00000000000000/* include/skypat/Config/Config.h.in. Generated from configure.ac by autoheader. */ /* Enable clock_gettime */ #undef ENABLE_CLOCK_GETTIME /* Enable gettimeofday */ #undef ENABLE_GETTIMEOFDAY /* the name of */ #undef HASH_MAP_CLASS /* the location of or */ #undef HASH_MAP_H /* the namespace of hash_map/hash_set */ #undef HASH_NAMESPACE /* the name of */ #undef HASH_SET_CLASS /* the location of or */ #undef HASH_SET_H /* Define to 1 if you have the header file. */ #undef HAVE_ASM_UNISTD_H /* Have clock_gettime */ #undef HAVE_CLOCK_GETTIME /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* define if the compiler has hash_map */ #undef HAVE_HASH_MAP /* define if the compiler has hash_set */ #undef HAVE_HASH_SET /* Define to 1 if the system has the type `int16_t'. */ #undef HAVE_INT16_T /* Define to 1 if the system has the type `int32_t'. */ #undef HAVE_INT32_T /* Define to 1 if the system has the type `int64_t'. */ #undef HAVE_INT64_T /* Define to 1 if the system has the type `int8_t'. */ #undef HAVE_INT8_T /* Define to 1 if the system has the type `intptr_t'. */ #undef HAVE_INTPTR_T /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_PERF_EVENT_H /* Define to 1 if the system has the type `long double'. */ #undef HAVE_LONG_DOUBLE /* Define to 1 if the type `long double' works and has more range or precision than `double'. */ #undef HAVE_LONG_DOUBLE_WIDER /* Define to 1 if the system has the type `long long'. */ #undef HAVE_LONG_LONG /* Define to 1 if the system has the type `long long int'. */ #undef HAVE_LONG_LONG_INT /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if the system has the type `off_t'. */ #undef HAVE_OFF_T /* Define if you have POSIX threads libraries and header files. */ #undef HAVE_PTHREAD /* Define to 1 if the system has the type `size_t'. */ #undef HAVE_SIZE_T /* Define to 1 if the system has the type `ssize_t'. */ #undef HAVE_SSIZE_T /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if the system has the type `uint16_t'. */ #undef HAVE_UINT16_T /* Define to 1 if the system has the type `uint32_t'. */ #undef HAVE_UINT32_T /* Define to 1 if the system has the type `uint64_t'. */ #undef HAVE_UINT64_T /* Define to 1 if the system has the type `uint8_t'. */ #undef HAVE_UINT8_T /* Define to 1 if the system has the type `uintptr_t'. */ #undef HAVE_UINTPTR_T /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if the system has the type `unsigned long long int'. */ #undef HAVE_UNSIGNED_LONG_LONG_INT /* Enable classes using zlib compression. */ #undef HAVE_ZLIB /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to necessary symbol if this constant uses a non-standard name on your system. */ #undef PTHREAD_CREATE_JOINABLE /* default target triple */ #undef SKYPAT_DEFAULT_TARGET_TRIPLE /* Define if this is Unixish platform */ #undef SKYPAT_ON_UNIX /* Define if this is Win32ish platform */ #undef SKYPAT_ON_WIN32 /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Version number of package */ #undef VERSION SkyPat-3.2.0/include/skypat/Listeners/000077500000000000000000000000001465531052300176415ustar00rootroot00000000000000SkyPat-3.2.0/include/skypat/Listeners/CSVResultPrinter.h000066400000000000000000000020121465531052300232030ustar00rootroot00000000000000//===- CSVResultPrinter.h -------------------------------------------------===// // // The skypat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_LISTENERS_CSV_RESULT_PRINTER_H #define SKYPAT_LISTENERS_CSV_RESULT_PRINTER_H #include #include #include namespace skypat { namespace testing { class UnitTest; class TestCase; class TestInfo; } // namespace of UnitTest //===----------------------------------------------------------------------===// // CSVResultPrinter //===----------------------------------------------------------------------===// class CSVResultPrinter : public skypat::testing::Listener { public: CSVResultPrinter(); ~CSVResultPrinter(); bool open(const std::string& pFileName); void OnTestEnd(const testing::TestInfo& pTestInfo); private: std::ofstream m_OStream; }; } // namespace skypat #endif SkyPat-3.2.0/include/skypat/Listeners/PrettyResultPrinter.h000066400000000000000000000023041465531052300240430ustar00rootroot00000000000000//===- PrettyResultPrinter.h ----------------------------------------------===// // // The skypat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_LISTENERS_PRETTY_RESULT_PRINTER_H #define SKYPAT_LISTENERS_PRETTY_RESULT_PRINTER_H #include #include namespace skypat { namespace testing { class UnitTest; class TestCase; class TestInfo; } // namespace of UnitTest //===----------------------------------------------------------------------===// // PrettyResultPrinter //===----------------------------------------------------------------------===// class PrettyResultPrinter : public skypat::testing::Listener { public: static void PrintCaseName(const std::string& pCase, const std::string& pTest); void OnTestProgramStart(const testing::UnitTest& pUnitTest); void OnTestCaseStart(const testing::TestCase& pTestCase); void OnTestStart(const testing::TestInfo& pTestInfo); void OnTestEnd(const testing::TestInfo& pTestInfo); void OnTestProgramEnd(const testing::UnitTest& pUnitTest); }; } // namespace skypat #endif SkyPat-3.2.0/include/skypat/SkypatNamespace.h000066400000000000000000000007011465531052300211300ustar00rootroot00000000000000//===- SkypatNamespace.h --------------------------------------------------===// // // The SkyPat team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_SKYPAT_NAMESPACE_H #define SKYPAT_SKYPAT_NAMESPACE_H namespace skypat { typedef void * HANDLE; } // namespace of skypat #endif SkyPat-3.2.0/include/skypat/Support/000077500000000000000000000000001465531052300173455ustar00rootroot00000000000000SkyPat-3.2.0/include/skypat/Support/IOSFwd.h000066400000000000000000000026501465531052300206140ustar00rootroot00000000000000//===- IOSFwd.h -----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_SUPPORT_IOSFWD_H #define SKYPAT_SUPPORT_IOSFWD_H #include #include namespace skypat { //===----------------------------------------------------------------------===// // Stream Forwarding //===----------------------------------------------------------------------===// template > class BasicOStream; template > class BasicFileBuf; template > class BasicOFStream; template, typename Alloc = std::allocator > class BasicOStringBuf; template, typename Alloc = std::allocator > class BasicOStrStream; /// @defgroup I/O Forward Declaration /// @{ typedef BasicOStream OStream; typedef BasicFileBuf FileBuf; typedef BasicOFStream OFStream; typedef BasicOStringBuf OStringBuf; typedef BasicOStrStream OStrStream; /// @} } // namespace of skypat #endif SkyPat-3.2.0/include/skypat/Support/ManagedStatic.h000066400000000000000000000051641465531052300222300ustar00rootroot00000000000000//===- ManagedStatic.h -----------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_SUPPORT_MANAGED_STATIC_H #define SKYPAT_SUPPORT_MANAGED_STATIC_H #include #include namespace skypat { template void ForEach(const Container& c, Functor functor) { std::for_each(c.begin(), c.end(), functor); } template void* object_creator() { return new C(); } template struct object_deleter { static void call(void * Ptr) { delete (T*)Ptr; } }; /// ManagedStaticBase - Common base class for ManagedStatic instances. class ManagedStaticBase { public: bool isConstructed() const { return (NULL != m_Ptr); } void destroy() const; protected: typedef void (*DeleterFuncType)(void*); protected: // This should only be used as a static variable, which guarantees that this // will be zero initialized. mutable void* m_Ptr; mutable DeleterFuncType m_pDeleter; mutable const ManagedStaticBase* m_pNext; void RegisterManagedStatic(void *(*creator)(), void (*deleter)(void*)) const; }; /** \class ManagedStatic * \brief ManagedStatic changes the behavior of global static variables to * be lazily constructed on demand and explicitly destructed by Shutdown() * function call. */ template class ManagedStatic : public ManagedStaticBase { public: // Accessors. C &operator*() { void* tmp = m_Ptr; if (NULL == tmp) RegisterManagedStatic(object_creator, object_deleter::call); return *static_cast(m_Ptr); } const C &operator*() const { void* tmp = m_Ptr; if (NULL == tmp) RegisterManagedStatic(object_creator, object_deleter::call); return *static_cast(m_Ptr); } C *operator->() { void* tmp = m_Ptr; if (NULL == tmp) RegisterManagedStatic(object_creator, object_deleter::call); return static_cast(m_Ptr); } const C *operator->() const { void* tmp = m_Ptr; if (NULL == tmp) RegisterManagedStatic(object_creator, object_deleter::call); return static_cast(m_Ptr); } }; /// shutdown - Deallocate and destroy all ManagedStatic variables. void shutdown(); /** \class Shutdown * \brief Shutdown is a helper class that call shutdown() when it's destroyed. */ class Shutdown : private testing::internal::Uncopyable { public: Shutdown() { } ~Shutdown() { shutdown(); } }; } // namespace of skypat #endif SkyPat-3.2.0/include/skypat/Support/OStrStream.h000066400000000000000000000063731465531052300215720ustar00rootroot00000000000000//===- OStream.h --------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_SUPPORT_OSTRSTREAM_H #define SKYPAT_SUPPORT_OSTRSTREAM_H #include #include #include namespace skypat { //===----------------------------------------------------------------------===// // Support::OStrStream //===----------------------------------------------------------------------===// /** \class BasicOStringBuf * \brief The actual work of input and output (for std::string) * * Unlike std::basic_stringbuf, BasicOStringBuf doesn't own a string for the * internal buffer. Otherwise, BasicOStringBuf uses the given string as the * internal buffer. Every change to the BasicOStringBuf also changes the * content of given string directly. */ template class BasicOStringBuf : public std::basic_streambuf { public: typedef CharT char_type; typedef Traits traits_type; typedef Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; typedef std::basic_streambuf streambuf_type; typedef std::basic_string string_type; typedef typename string_type::size_type size_type; public: explicit BasicOStringBuf(string_type& pStr, std::ios_base::openmode pMode = std::ios_base::out); ~BasicOStringBuf() { } /// str - return a copy string_type str() const; protected: void BasicOStringBufInit(std::ios_base::openmode pMode); void doSync(char_type* pBase, size_type pO); int_type overflow(int_type pC = traits_type::eof()); std::streamsize xsputn(const char_type* pS, std::streamsize pN); protected: std::ios_base::openmode m_Mode; string_type& m_String; }; /** \class BasicOStrStream * \brief BasicOStrStream is an OStream that writes to an std::string. */ template class BasicOStrStream : public std::basic_ostream { public: typedef CharT char_type; typedef Traits traits_type; typedef Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // Non-standard types: typedef std::basic_string string_type; typedef BasicOStringBuf stringbuf_type; typedef std::basic_ostream ostream_type; public: explicit BasicOStrStream(string_type& pStr, std::ios_base::openmode pMode = std::ios_base::out); /// Destructor - does nothing ~BasicOStrStream() {} stringbuf_type* rdbuf() const { return const_cast(&m_StringBuf); } /// str - get a copy of output stream string_type str() const { return m_StringBuf.str(); } private: stringbuf_type m_StringBuf; }; } // namespace of skypat #include "OStrStream.tcc" #endif SkyPat-3.2.0/include/skypat/Support/OStrStream.tcc000066400000000000000000000106211465531052300221030ustar00rootroot00000000000000//===- OStream.tcc --------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // BasicOStringBuf //===----------------------------------------------------------------------===// template skypat::BasicOStringBuf::BasicOStringBuf(string_type& pStr, std::ios_base::openmode pMode) : streambuf_type(), m_Mode(), m_String(pStr) { BasicOStringBufInit(pMode); } template void skypat::BasicOStringBuf::BasicOStringBufInit( std::ios_base::openmode pMode) { m_Mode = pMode; size_type len = 0; if (m_Mode & (std::ios_base::ate | std::ios_base::app)) len = m_String.size(); doSync(const_cast(m_String.data()), len); } /// doSync - Internal function for correctly updating the internal buffer /// for particular m_String. template void skypat::BasicOStringBuf::doSync(char_type* pBase, size_type pO) { char_type* endp = pBase + m_String.capacity(); this->setp(pBase, endp); this->pbump(pO); } template typename skypat::BasicOStringBuf::string_type skypat::BasicOStringBuf::str() const { return m_String; } template typename skypat::BasicOStringBuf::int_type skypat::BasicOStringBuf::overflow(int_type pC) { const bool testout = this->m_Mode & std::ios_base::out; if (!testout) return traits_type::eof(); const bool testeof = traits_type::eq_int_type(pC, traits_type::eof()); if (testeof) return traits_type::not_eof(pC); const size_type capacity = m_String.capacity(); const size_type max_size = m_String.max_size(); const bool testput = this->pptr() < this->epptr(); if (!testput && capacity == max_size) return traits_type::eof(); // try to append pC into output sequence const char_type conv = traits_type::to_char_type(pC); if (!testput) { string_type tmp; // magic number. 512 looks like the best configuration on Mac OSX, 64 bits. const size_type opt_len = std::max(size_type(2 * capacity), size_type(512)); tmp.reserve(std::min(opt_len, max_size)); if (this->pbase()) tmp.assign(this->pbase(), this->epptr() - this->pbase()); tmp.push_back(conv); m_String.swap(tmp); doSync(const_cast(m_String.data()), this->pptr()-this->pbase()); } else { // Although pptr >= epptr, we still have capacity. *this->pptr() = conv; } this->pbump(1); return pC; } template std::streamsize skypat::BasicOStringBuf::xsputn(const char_type* pS, std::streamsize pN) { std::streamsize result = 0; while (result < pN) { const std::streamsize buf_len = this->epptr() - this->pptr(); if (buf_len) { const std::streamsize remaining = pN - result; const std::streamsize len = std::min(buf_len, remaining); // In order to correct m_String's bookkeeping, use append instead of // char_traits::copy. m_String.append(pS, len); result += len; pS += len; this->pbump(len); } if (result < pN) { int_type c = this->overflow(traits_type::to_int_type(*pS)); if (!traits_type::eq_int_type(c, traits_type::eof())) { ++result; ++pS; } else break; } } return result; } //===----------------------------------------------------------------------===// // BasicOStrStream //===----------------------------------------------------------------------===// template skypat::BasicOStrStream::BasicOStrStream(string_type& pStr , std::ios_base::openmode pMode) : ostream_type(), m_StringBuf(pStr, pMode | std::ios_base::out) { this->init(&m_StringBuf); } SkyPat-3.2.0/include/skypat/Support/Path.h000066400000000000000000000176371465531052300204300ustar00rootroot00000000000000//===- Path.h -------------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// // This file declares the skypat::Path. It follows TR2/boost // filesystem (v3), but modified to remove exception handling and RTTI. //===----------------------------------------------------------------------===// #ifndef SKYPAT_SUPPORT_PATH_H #define SKYPAT_SUPPORT_PATH_H #include #include #include namespace skypat { /** \class Path * \brief Path provides an abstraction for the path to a file or directory in * the operating system's filesystem. * * Path is concerned only with the lexical and syntactic aspects of a path * name. The path name does not necessarily exist in external storage, and * path name is not necessarily valid for the current operating system or for * a particular file system. * * Native path name format is implementation-defined. Current storage type of * native format is std::string. */ class Path { public: typedef char ValueType; typedef std::string StringType; public: static const char separator; static const char preferred_separator; static const StringType separator_str; static const char colon; static const char dot; public: /// empty path. Path(); /// Stores the path name to the native format. Path(const ValueType* pPathName); /// Stores the path name to the native format. Path(const StringType &pPathName); /// Copy the native format from pCopy. Path(const Path& pCopy); /// Destructor virtual ~Path(); /// Store the content [begin, end) in path name by native format. template Path& assign(InputIterator begin, InputIterator end); /// Assign \ref pPathName in native format. Path& assign(const StringType &pPathName); /// Assign \ref pPathName in native format. Path& assign(const ValueType* s, unsigned int length); /// Append the content [begin, end) in the native format. The append /// operations also appends the platform's preferred dictionary /// separator when needed. The preferred dictionary separator is /// implementation defined. In Unix platforms, it's '/' in general. template Path& append(InputIterator begin, InputIterator end); /// Append the \ref pPathName in the native format. The append /// operations also appends the platform's preferred dictionary /// separator when needed. The preferred dictionary separator is /// implementation defined. In Unix platforms, it's '/' in general. Path& append(const Path& pPathName); /// Check if the native format is empty. bool empty() const; /// Check if the path is absolutely starting from root. bool isFromRoot() const; /// Check if the path is starting from the current working folder. bool isFromPWD() const; /// Returns the native format. const StringType& native() const { return m_PathName; } /// Returns the native format. StringType& native() { return m_PathName; } /// Compares the value of the string object. /// @param [in] pString the target string. /// @return If they compare equal, then return 0; /// If \ref pString is longer, then return > 0; /// If \ref pString is shorter, then return < 0; int compare(const char* pString) const; /// Compares the value of the string object. /// @param [in] pString the target string. /// @return If they compare equal, then return 0; /// If \ref pString is shorter, then return < 0; /// If \ref pString is longer, then return > 0; int compare(const std::string& pString) const { return compare(pString.c_str()); } /// Compares the value of the string object. /// @param [in] pString the target string. /// @return If they compare equal, then return 0; /// If \ref pString is shorter, then return < 0; /// If \ref pString is longer, then return > 0; int compare(const Path& pString) const { return compare(pString.c_str()); } /// Returns the native format by C-style string. const ValueType* c_str() const { return m_PathName.c_str(); } /// @name Decomposition /// @{ /// Returns the parent path. For example, if the path name is ./abc/XYZ/file, /// then its parent path is './abc/XYZ' Path parent_path() const; /// Returns the file name. For example, if the path name is ./abc/XYZ/file, /// then its parent path is 'file'. Path filename() const; /// Return the stem of the file name. For example, if the path name is /// ./abc/XYZ/stem.extension, then its stem is 'stem'. Path stem() const; /// Return the extension of the file name. For example, if the path name is /// ./abc/XYZ/stem.extension, then its extension is 'extension'. Path extension() const; /// @} /// Return the canonical form of the path name. A canonical form is a path /// that has no elements which are symbolic links, and not dot or dot dot /// elements. StringType generic_string() const; /// Change the native format to canonical form. A canonical form is a path /// that has no elements which are symbolic links, and not dot or dot dot bool canonicalize(); protected: StringType::size_type AppendSeparatorAsNeeded(); void EraseRedundantSeparator(StringType::size_type sep_pos); protected: StringType m_PathName; }; bool operator==(const Path& pLHS,const Path& pRHS); bool operator!=(const Path& pLHS,const Path& pRHS); Path operator+(const Path& pLHS, const Path& pRHS); //===----------------------------------------------------------------------===// // System dependent non-member functions //===----------------------------------------------------------------------===// namespace sys { /// Canonicalizes the path. size_t canonicalize(Path::StringType& pPathName); /// Check if \ref pValue is the separator of the path in the system. bool is_separator(char pValue); } // namespace of sys //===----------------------------------------------------------------------===// // Non-member functions //===----------------------------------------------------------------------===// template inline std::basic_ostream& operator<<(std::basic_ostream& pOS, const Path& pPath) { return pOS << pPath.native(); } template inline std::basic_istream& operator>>(std::basic_istream& pOS, Path& pPath) { return pOS >> pPath.native(); } //===----------------------------------------------------------------------===// // class path member template implementation //===----------------------------------------------------------------------===// template Path& Path::assign(InputIterator begin, InputIterator end) { m_PathName.clear(); if (begin != end) m_PathName.append(begin, end); return *this; } template Path& Path::append(InputIterator begin, InputIterator end) { if (begin == end) return *this; StringType::size_type sep_pos(AppendSeparatorAsNeeded()); m_PathName.append(begin, end); if (sep_pos) EraseRedundantSeparator(sep_pos); return *this; } } // namespace of skypat //===----------------------------------------------------------------------===// // STL compatible functions //===----------------------------------------------------------------------===// namespace std { template<> struct less : public binary_function { bool operator() (const skypat::Path& pX,const skypat::Path& pY) const { if (pX.generic_string().size() < pY.generic_string().size()) return true; return (pX.generic_string() < pY.generic_string()); } }; } // namespace of std #endif SkyPat-3.2.0/include/skypat/Support/Perf.h000066400000000000000000000020731465531052300204140ustar00rootroot00000000000000//===- Perf.h ------------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_SUPPORT_PERF_H #define SKYPAT_SUPPORT_PERF_H #include namespace skypat { namespace testing { namespace internal { //===----------------------------------------------------------------------===// // Perf //===----------------------------------------------------------------------===// class Perf { public: Perf(); Perf(enum PerfEvent pEvent); ~Perf(); bool isActive() const { return m_bIsActive; } testing::Interval interval() const { return m_Interval; } testing::Interval eventType() const { return m_EventType; } void start(); void stop(); static std::string unit(); private: testing::Interval m_Interval, m_EventType; bool m_bIsActive; }; } // namespace of internal } // namespace of testing } // namespace of skypat #endif SkyPat-3.2.0/include/skypat/Support/Timer.h000066400000000000000000000017301465531052300205770ustar00rootroot00000000000000//===- Timer.h ------------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_SUPPORT_TIMER_H #define SKYPAT_SUPPORT_TIMER_H #include namespace skypat { namespace testing { namespace internal { //===----------------------------------------------------------------------===// // Timer //===----------------------------------------------------------------------===// class Timer { public: Timer(); ~Timer(); bool isActive() const { return m_bIsActive; } testing::Interval interval() const { return m_Interval; } void start(); void stop(); static std::string unit(); private: testing::Interval m_Interval; bool m_bIsActive; }; } // namespace of internal } // namespace of testing } // namespace of skypat #endif SkyPat-3.2.0/include/skypat/Thread/000077500000000000000000000000001465531052300171005ustar00rootroot00000000000000SkyPat-3.2.0/include/skypat/Thread/Mutex.h000066400000000000000000000023661465531052300203620ustar00rootroot00000000000000//===- Mutex.h ------------------------------------------------------------===// // // The SkyPat team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_MUTEX_H #define SKYPAT_MUTEX_H #include namespace skypat { class MutexData; class WaitCondition; /** \class Mutex * \brief The Mutex class provides access serialization between threads. */ class Mutex : private Uncopyable { public: enum Status { Success, Busy, Invalid, UnknownError }; public: Mutex(); ~Mutex(); void lock() throw(); void unlock() throw(); Status tryLock() throw(); private: friend class WaitCondition; const MutexData* data() const { return m_pData; } MutexData* data() { return m_pData; } private: mutable MutexData* m_pData; }; /** \class ScopedLock * \brief ScopedLock defines a scope as a mutual-execlusive region. */ class ScopedLock : private Uncopyable { public: ScopedLock(Mutex& pMutex) : m_Mutex(pMutex) { m_Mutex.lock(); } ~ScopedLock() { m_Mutex.unlock(); } private: Mutex& m_Mutex; }; } // namespace of skypat #endif SkyPat-3.2.0/include/skypat/Thread/MutexImpl.h000066400000000000000000000017411465531052300212000ustar00rootroot00000000000000//===- MutexImpl.h --------------------------------------------------------===// // // The SkyPat team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_THREAD_MUTEX_IMPL_H #define SKYPAT_THREAD_MUTEX_IMPL_H #include // // W A R N I N G // ------------- // // This file is not part of the skypat API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // // //===----------------------------------------------------------------------===// // MutexData //===----------------------------------------------------------------------===// #if defined(HAVE_PTHREAD) #include namespace skypat { struct MutexData { pthread_mutex_t mutex; }; } /// namespace of skypat #endif #endif SkyPat-3.2.0/include/skypat/Thread/Thread.h000066400000000000000000000021051465531052300204560ustar00rootroot00000000000000//===- Thread.h -----------------------------------------------------------===// // // The SkyPat team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_THREAD_THREAD_H #define SKYPAT_THREAD_THREAD_H #include namespace skypat { class ThreadData; class ThreadImpl; /** \class Thread * \brief Thread provides the abstract interface for threads. */ class Thread { public: Thread(); virtual ~Thread(); /// start - Begins execution of the thread. void start(); /// join - Wait the execution of thread complete. This is similar to /// the functionality to pthread_join. bool join(); HANDLE getThreadID() const; protected: friend class ThreadImpl; virtual void run() = 0; const ThreadData* data() const; ThreadData* data(); const ThreadImpl* impl() const; ThreadImpl* impl(); protected: ThreadImpl* m_pThreadImpl; }; } // namespace of skypat #endif SkyPat-3.2.0/include/skypat/Thread/ThreadImpl.h000066400000000000000000000031131465531052300213000ustar00rootroot00000000000000//===- ThreadImpl.h -------------------------------------------------------===// // // The SkyPat team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_THREAD_THREAD_IMPL_H #define SKYPAT_THREAD_THREAD_IMPL_H #include #include #include #include //#include #include #if defined(HAVE_PTHREAD) #include #endif // // W A R N I N G // ------------- // // This file is not part of the "skypat" API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // // namespace skypat { /** \class ThreadData * \brief ThreadData stores thread specific data */ class ThreadData { public: ThreadData(); ~ThreadData(); static ThreadData* current(); static void SetUp(ThreadData*& pData, Thread& pThread); public: Thread* thread; }; /** \class ThreadImpl * \brief ThreadImpl provides the interface for the implementation of * Thread. */ class ThreadImpl { public: ThreadImpl(Thread* pParent = NULL); ~ThreadImpl(); static void* start(void* pArg); static void finish(void* pArg); public: #if defined(HAVE_PTHREAD) pthread_t thread_id; #else HANDLE thread_id; #endif ThreadData* data; Thread* parent; }; } // namespace of skypat #endif SkyPat-3.2.0/include/skypat/skypat.h000066400000000000000000000664071465531052300173720ustar00rootroot00000000000000//===- skypat.h -----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_SKYPAT_H #define SKYPAT_SKYPAT_H #include #include #include #include #include #define SKYPAT_VERNUM 0x24 namespace skypat { enum PerfEvent { // type is PERF_TYPE_HARDWARE CPU_CYCLES, // = 0 INSTRUCTIONS, CACHE_REFERENCES, CACHE_MISSES, BRANCH_INSTRUCTIONS, BRANCH_MISSES, BUS_CYCLES, STALLED_CYCLES_FRONTEND, STALLED_CYCLES_BACKEND, REF_CPU_CYCLES, // = 9 // type is PERF_TYPE_SOFTWARE CPU_CLOCK, // = 10 TASK_CLOCK, PAGE_FAULTS, CONTEXT_SWITCHES, CPU_MIGRATIONS, PAGE_FAULTS_MIN, PAGE_FAULTS_MAJ, ALIGNMENT_FAULTS, EMULATION_FAULTS // = 18 }; enum PerfEventCache{ // type is PERF_TYPE_HW_CACHE // TODO: add CPU cache events }; extern char const *Perf_event_name[]; class Test; namespace testing { namespace internal { class Timer; class Perf; //===----------------------------------------------------------------------===// // ADT //===----------------------------------------------------------------------===// class Uncopyable { protected: Uncopyable() { } ~Uncopyable() { } private: Uncopyable(const Uncopyable&); /// NOT TO IMPLEMENT Uncopyable& operator=(const Uncopyable&); /// NOT TO IMPLEMENT }; } // namespace of internal //===----------------------------------------------------------------------===// // Forward Declaration //===----------------------------------------------------------------------===// class AssertionResult; class TestCase; class TestInfo; class TestResult; class TestFactoryBase; class PartResult; class TestPartResult; class PerfPartResult; class UnitTest; // Expands to the name of the class that implements the given test. #define SKYPAT_TEST_CLASS_NAME_(case_name, test_name) \ case_name##_##test_name##_Test /// Helper macro for defining Cases. #define SKYPAT_TEST_CASE(case_name, test_name, parent_class)\ class SKYPAT_TEST_CLASS_NAME_(case_name, test_name) : public parent_class {\ public:\ SKYPAT_TEST_CLASS_NAME_(case_name, test_name)() {}\ private:\ virtual void TestBody();\ static skypat::testing::TestInfo* const m_TestInfo;\ };\ \ skypat::testing::TestInfo* const SKYPAT_TEST_CLASS_NAME_(case_name, test_name)\ ::m_TestInfo =\ skypat::testing::MakeAndRegisterTestInfo(\ #case_name, #test_name, \ new skypat::testing::TestFactory<\ SKYPAT_TEST_CLASS_NAME_(case_name, test_name)>);\ void SKYPAT_TEST_CLASS_NAME_(case_name, test_name)::TestBody() /// Helper macro for defining SystemC Cases. #define SKYPAT_SYSTEMC_TEST_CASE(case_name, test_name, parent_class)\ class SKYPAT_TEST_CLASS_NAME_(case_name, test_name) : public parent_class {\ public:\ SKYPAT_TEST_CLASS_NAME_(case_name, test_name)() {}\ virtual void SetUp() { sc_get_curr_simcontext()->reset(); } \ private:\ virtual void TestBody();\ static skypat::testing::TestInfo* const m_TestInfo;\ };\ \ skypat::testing::TestInfo* const SKYPAT_TEST_CLASS_NAME_(case_name, test_name)\ ::m_TestInfo =\ skypat::testing::MakeAndRegisterTestInfo(\ #case_name, #test_name, \ new skypat::testing::TestFactory<\ SKYPAT_TEST_CLASS_NAME_(case_name, test_name)>);\ void SKYPAT_TEST_CLASS_NAME_(case_name, test_name)::TestBody() // The message handling macros. The assignment is used to trigger recording a // partial result. #define SKYPAT_MESSAGE_AT(file, line, message, result_type) \ skypat::testing::AssertHelper(result_type, file, line, message) = \ skypat::testing::Message() #define SKYPAT_MESSAGE(message, result_type) \ SKYPAT_MESSAGE_AT(__FILE__, __LINE__, message, result_type) // SKYPAT_FATAL_FAILURE is a run-time result of fatal error #define SKYPAT_FATAL_FAILURE(message) \ return SKYPAT_MESSAGE(message, skypat::testing::TestPartResult::kFatalFailure) // SKYPAT_NON_FATAL_FAILURE is a run-time result of expectation error #define SKYPAT_NONFATAL_FAILURE(message) \ SKYPAT_MESSAGE(message, skypat::testing::TestPartResult::kNonFatalFailure) // SKYPAT_SUCCESS is a run-time result of success. #define SKYPAT_SUCCESS(message) \ SKYPAT_MESSAGE(message, skypat::testing::TestPartResult::kSuccess) // The GNU compiler emits a warning if nested "if" statements are followed by // an "else" statement and braces are not used to explicitly disambiguate the // "else" binding. #ifdef __INTEL_COMPILER # define SKYPAT_UNAMBIGUOUS_ELSE_BLOCKER #else # define SKYPAT_UNAMBIGUOUS_ELSE_BLOCKER switch (0) case 0: default: // NOLINT #endif // Implements Boolean test assertions such as EXPECT_TRUE. expression can be // either a boolean expression or an AssertionResult. text is a textual // represenation of expression as it was passed into the EXPECT_TRUE. // // The last parameter 'fail' is the run-time result of the testing #define SKYPAT_TEST_BOOLEAN(expression, text, actual, expected, fail) \ SKYPAT_UNAMBIGUOUS_ELSE_BLOCKER \ if (const skypat::testing::AssertionResult _ar_ = \ skypat::testing::AssertionResult(expression)) \ SKYPAT_SUCCESS(""); \ else \ fail(skypat::testing::GetBoolAssertionFailureMessage(\ _ar_, text, #actual, #expected)) // Implements Predicate test assertions such as EXPECT_EQ. // // The last parameter 'fail' is the run-time result of the testing #define SKYPAT_TEST_PREDICATE(expression, text, actual, expected, fail) \ SKYPAT_UNAMBIGUOUS_ELSE_BLOCKER \ if (const skypat::testing::AssertionResult _ar_ = \ skypat::testing::AssertionResult(expression)) \ SKYPAT_SUCCESS(""); \ else \ fail(skypat::testing::GetPredAssertionFailureMessage(\ _ar_, text, actual, #actual, expected, #expected)) //===----------------------------------------------------------------------===// // Supports //===----------------------------------------------------------------------===// /// Interval - the unit of time. typedef uint64_t Interval; //===----------------------------------------------------------------------===// // Core //===----------------------------------------------------------------------===// class TestFactoryBase { public: virtual ~TestFactoryBase() { } virtual skypat::Test* CreateTest() = 0; }; template struct TestFactory : public TestFactoryBase { virtual skypat::Test* CreateTest() { return new SingleTest; } }; /** \class PerfIterator * \brief PerfIterator is used to calculate the computing time of a * performance test. */ class PerfIterator { public: /// @param pFileName the source file name. /// @param pLoC the line of code. PerfIterator(const char* pFileName, int pLoC); /// @param pFileName the source file name. /// @param pLoC the line of code. /// @param pFlavor the flavor of event (COUNT / SAMPLE) /// @param pType the type of event (HW / SW) /// @param pEvent the name of event PerfIterator(const char* pFileName, int pLoC,\ enum PerfEvent pEvent); /// Destructor. The place to sum up the time. ~PerfIterator(); /// increase counter PerfIterator& next(); /// @return true if we should go to the next step. bool hasNext() const; private: int m_Counter; internal::Timer* m_pTimer; internal::Perf* m_pPerf; PerfPartResult* m_pPerfResult; }; /** \class PartResult * \brief The partial result of a single test */ class PartResult { public: PartResult(const std::string& pFileName, int pLoC); PartResult(const std::string& pFileName, int pLoC, const std::string& pMessage); virtual ~PartResult() { } const std::string& filename() const { return m_FileName; } int lineNumber() const { return m_LoC; } const std::string& message() const { return m_Message; } protected: void update_message(const std::string& pMessage) { m_Message = pMessage; } protected: std::string m_FileName; int m_LoC; std::string m_Message; }; /** \class TestPartResult * \brief The partial result of a single test */ class TestPartResult : public PartResult { public: enum Type { kSuccess, ///< Succeeded. kNonFatalFailure, ///< Failed but the test can continue. kFatalFailure ///< Failed and the test should be terminated. }; public: TestPartResult(Type pType, const std::string& pFileName, int pLoC, const std::string& pMessage); Type type() const { return m_Type; } TestPartResult& appendUserMessage(const std::string& pMessage); private: Type m_Type; }; /** \class TestPerfPartResult * \brief The performance result */ class PerfPartResult : public PartResult { public: PerfPartResult(const std::string& pFileName, int pLoC); Interval getTimerNum() const; Interval getPerfEventNum() const; Interval getPerfEventType() const; void setTimerNum(Interval pTime); void setPerfEventNum(Interval pEventNum); void setPerfEventType(Interval pEventType); private: Interval m_PerfTimerNum; Interval m_PerfEventNum; Interval m_PerfEventType; }; /** \class TestResult * \brief The result of a single test. * * TestResult concludes the result of a single test in summary. */ class TestResult : private skypat::testing::internal::Uncopyable { public: typedef std::vector Reliability; typedef std::vector Performance; public: enum Conclusion { kPassed, ///< we pass all assertions kFailed, ///< we fail some assertions kNotTested ///< we do not have any assertions }; public: TestResult(const TestInfo& pInfo); ~TestResult(); bool isPassed() const; bool isFailed() const; Conclusion conclusion() const { return m_Conclusion; } void setConclusion(Conclusion pConclusion) { m_Conclusion = pConclusion; } const Performance& performance() const; const Reliability& reliability() const; private: const TestInfo& m_Info; Conclusion m_Conclusion; }; /** \class TestCase * \brief The information of a test case (a set of tests) */ class TestCase { private: typedef std::vector InfoList; public: typedef InfoList::iterator iterator; typedef InfoList::const_iterator const_iterator; const_iterator begin() const { return m_InfoList.begin(); } iterator begin() { return m_InfoList.begin(); } const_iterator end() const { return m_InfoList.end(); } iterator end() { return m_InfoList.end(); } public: TestCase(const std::string& pCaseName); ~TestCase(); testing::TestInfo* addTestInfo(const std::string& pTestName, testing::TestFactoryBase& pFactory); const std::string& getCaseName() const { return m_CaseName; } unsigned int getNumOfTests() const { return m_InfoList.size(); } private: InfoList m_InfoList; std::string m_CaseName; }; /** \class TestInfo * \brief The information of a single test. * * TestInfo stores the information of a single test. A test case contains * multiple tests which is represented by TestInfos. * * TestInfo is created at static time and gathers partial results at run-time. */ class TestInfo { public: TestInfo(TestCase* pTestCase, const std::string& pTestName, TestFactoryBase& pFactory); ~TestInfo(); const TestCase* testCase() const { return m_pTestCase; } const std::string& getCaseName() const { return m_pTestCase->getCaseName(); } const std::string& getTestName() const { return m_TestName; } const TestResult& result() const { return m_Result; } /// run - run a single test function and notifiy repeater. void run(); void addTestPartResult(const TestPartResult& pResult); PerfPartResult* addPerfPartResult(const char* pFile, int pLine); private: friend class TestResult; typedef std::vector TestPartResultList; typedef std::vector PerfPartResultList; private: const TestPartResultList& getTestResults() const { return m_TestResultList; } TestPartResultList& getTestResults() { return m_TestResultList; } const PerfPartResultList& getPerfResults() const { return m_PerfResultList; } PerfPartResultList& getPerfResults() { return m_PerfResultList; } private: TestCase* m_pTestCase; std::string m_TestName; TestResult m_Result; TestFactoryBase* m_pFactory; TestPartResultList m_TestResultList; PerfPartResultList m_PerfResultList; }; /** \class AssertionResult * \brief The result of an assertion. */ class AssertionResult { public: AssertionResult(const AssertionResult& other); explicit AssertionResult(bool pSuccess); operator bool() const { return m_bSuccess; } // NOLINT AssertionResult operator!() const; const std::string& message() const { return m_Message; } template AssertionResult& operator<<(const T& pValue); AssertionResult& operator<<( ::std::ostream& (*basic_manipulator)(::std::ostream& stream)); bool hasMessage() const { return !m_Message.empty(); } private: bool m_bSuccess; std::string m_Message; }; /** \class Message * \brief Message is a carrier to pass user-defined message to AssertionResult */ class Message { public: Message(); template inline Message& operator <<(const T& pValue) { m_OSS << pValue; return *this; } template inline Message& operator <<(T* const& pPointer) { if (NULL == pPointer) m_OSS << "(null)"; else m_OSS << pPointer; return *this; } const std::string& str() const { return m_Message; } private: std::string m_Message; OStrStream m_OSS; }; /** \class AssertHelper * \brief AssertHelper carries all information to UnitTest. */ class AssertHelper { public: AssertHelper(TestPartResult::Type pType, const std::string& pFile, int pLineOfCode, const std::string& pMessage); // Message assignment is a semantic trick to enable assertion // streaming; see the SKYPAT_MESSAGE_AT macro below. // This method may update the messages stored in TestPartResult. void operator=(const Message& pMesg); private: TestPartResult m_Result; }; TestInfo* MakeAndRegisterTestInfo( const char* pCaseName, const char* pTestName, TestFactoryBase* pFactory); std::string GetBoolAssertionFailureMessage( const AssertionResult& pAssertionResult, const char* pExpressionText, const char* pActualPredicateValue, const char* pExpectedPredicateValue); template std::string GetPredAssertionFailureMessage( const AssertionResult& pAssertionResult, const char* pExpressionText, const T1& pActualPredicateValue, const char* pActualPredicate, const T2& pExpectedPredicateValue, const char* pExpectedPredicate) { std::string result; OStrStream OS(result); OS << "Value of: " << pExpressionText << "\n Actual: " << pActualPredicateValue; if (pAssertionResult.hasMessage()) OS << "(" << pAssertionResult.message() << ")"; OS << "\n Expected: " << pExpectedPredicateValue; return result; } //===----------------------------------------------------------------------===// // Listener //===----------------------------------------------------------------------===// /** \class Listener * \brief Listener provides interfaces for objects who wants UnitTest's events. */ class Listener { public: virtual ~Listener() { } // Fired before any test activity starts. virtual void OnTestProgramStart(const testing::UnitTest& pUnitTest) {} // Fired before each test case (a set of tests) of test start. virtual void OnTestCaseStart(const TestCase& pTestCase) {} // Fired before set-up for each iteration of test start. virtual void OnSetUpStart(const UnitTest& pUnitTest) {} // Fired before set-up for each iteration of test end. virtual void OnSetUpEnd(const UnitTest& pUnitTest) {} // Fired before the test starts. virtual void OnTestStart(const TestInfo& pTestInfo) {} // Fired after a failed assertion or a SUCCEED() invocation. virtual void OnTestPartResult(const TestPartResult& pTestPartResult) {} // Fired after a PERFORM invocation virtual void OnPerfPartResult(const PerfPartResult& pPerfPartResult) {} // Fired after the test ends. virtual void OnTestEnd(const TestInfo& pTestInfo) {} // Fired before environment tear-down for each iteration of tests starts. virtual void OnTearDownStart(const UnitTest& pUnitTest) {} // Fired after environment tear-down for each iteration of tests ends. virtual void OnTearDownEnd(const UnitTest& pUnitTest) {} // Fired after each test case (a set of tests) of test ends. virtual void OnTestCaseEnd(const TestCase& pTestCase) {} // Fired after all test activities have ended. virtual void OnTestProgramEnd(const UnitTest& pUnitTest) {} }; class Log { public: enum Severity { kInfo, kWarning, kError, kFatal }; public: Log(Severity pSeverity, const std::string& pFileName, int pLoC); /// Destructor. Flush the buffers and if the Severity is fatal, aborts the /// program. ~Log(); static ::std::ostream& getOStream(); static std::string FormatFileLocation(const std::string& pFileName, int pLoC); private: Severity m_Severity; }; //===----------------------------------------------------------------------===// // Repeater //===----------------------------------------------------------------------===// /** \class Repeater * \brief Repeater dispatches events to all listeners. */ class Repeater : public Listener { public: typedef std::vector ListenerList; public: Repeater(); ~Repeater(); void add(Listener* pListener); void release(Listener& pListener); bool isForward() const { return m_bForward; } void setForward(bool pEnable = true) { m_bForward = pEnable; } void OnTestProgramStart(const testing::UnitTest& pUnitTest); void OnTestCaseStart(const TestCase& pTestCase); void OnSetUpStart(const UnitTest& pUnitTest); void OnSetUpEnd(const UnitTest& pUnitTest); void OnTestStart(const TestInfo& pTestInfo); void OnTestPartResult(const TestPartResult& pTestPartResult); void OnPerfPartResult(const PerfPartResult& pPerfPartResult); void OnTestEnd(const TestInfo& pTestInfo); void OnTearDownStart(const UnitTest& pUnitTest); void OnTearDownEnd(const UnitTest& pUnitTest); void OnTestCaseEnd(const TestCase& pTestCase); void OnTestProgramEnd(const UnitTest& pUnitTest); private: ListenerList m_Listeners; bool m_bForward; }; //===----------------------------------------------------------------------===// // UnitTest //===----------------------------------------------------------------------===// class UnitTest { private: typedef std::map CaseMap; // RunCases stores all runnable cases typedef std::vector RunCases; public: static UnitTest* self() { static UnitTest instance; return &instance; } void RunAll(); /// addRunCase - add the test case to run /// @return true if the case exists (be stored at static-time). bool addRunCase(const std::string& pCaseName); /// addAllRunCase - add all test cases to run void addAllRunCases(); /// addTestInfo - store a TestInfo at static-time testing::TestInfo* addTestInfo(const std::string& pCaseName, const std::string& pTestName, testing::TestFactoryBase& pFactory); /// addTestPartResult - add partial test result at run-time. void addTestPartResult(const testing::TestPartResult& pPartResult); /// addPerfPartResult - add partial performance result at run-time. testing::PerfPartResult* addPerfPartResult(const char* pFile, int pLine); const Repeater& repeater() const { return m_Repeater; } Repeater& repeater() { return m_Repeater; } unsigned int getNumOfCases() const { return m_CaseMap.size(); } unsigned int getNumOfTests() const { return m_NumOfTests; } unsigned int getNumOfFails() const { return m_NumOfFails; } unsigned int getNumOfRunCases() const { return m_RunCases.size(); } private: UnitTest(); ~UnitTest(); UnitTest(const UnitTest& pCopy); // DO NOT IMPLEMENT UnitTest& operator=(const UnitTest& pCopy); // DO NOT IMPLEMENT private: CaseMap m_CaseMap; RunCases m_RunCases; testing::Repeater m_Repeater; testing::TestInfo* m_pCurrentInfo; unsigned int m_NumOfTests; unsigned int m_NumOfFails; }; } // namespace of testing /** \class Test * \brief Test is the abstract class that all tests inherit from. * * In skypat, a performance test program contains one or many TestCases, and * each TestCase contains one or many Tests. * * When you define a test using the TEST macro, you don't need to explicitly * derive from Test - the PERFORM macro automatically does this for you. * * The only one time you derive from Test is when defining a test fixture * to be used a PERFORM_F. For example: * * class FooTest : public skypat::Test * { * public: * virtual void SetUp() { ... } * virtual void TearDown() { ... } * ... * }; * * SKYPAT_C( FooTest, Bar1) { ... } * SKYPAT_C( FooTest, Bar2) { ... } */ class Test : private skypat::testing::internal::Uncopyable { friend class skypat::testing::TestInfo; private: void run(); public: /// Destructor virtual ~Test() = 0; /// SetUp - set up the test fixture. virtual void SetUp() { } /// TearDown - tears down the test fixture. virtual void TearDown() { } public: /// @name Static Member Functions /// @{ /// Initialize - initialize environment for TestCases. static void Initialize(const int& pArgc, char* pArgv[]); /// Initialize - use the pretty printer /// @param[out] pProgName The program name. static void Initialize(const std::string& pProgName); /// Initialize - initialize environment for TestCases. /// @param[out] pProgName The program name. /// @param[out] pCSVResult The resulting CSV file. static void Initialize(const std::string& pProgName, const std::string& pCSVResult); /// RunAll - run all TestCases. static void RunAll(); /// Sleep - sleep for micro seconds static void Sleep(int pMS); /// @} virtual void TestBody() = 0; }; // Defines a test that uses a test fixture. // // SKYPAT_C defines a skypat case. // SKYPAT_F defines a skypat function. // // The first parameter is the name of the test fixture class, which // also doubles as the test case name. The second parameter is the // name of the test within the test case. // // A test fixture class must be declared earlier. The user should put // his test code between braces after using this macro. Example: // // class FooTest : public skypat::Test { // protected: // virtual void SetUp() { m_B.AddElement(3); } // // Foo m_A; // Foo m_B; // }; // // SKYPAT_C(FooTest, Initializes) { // m_A.StatusIsOK(); // } // #define SKYPAT_C(test_fixture, test_name) \ SKYPAT_TEST_CASE(test_fixture, test_name, test_fixture) #define SKYPAT_F(test_fixture, test_name) \ SKYPAT_TEST_CASE(test_fixture, test_name, skypat::Test) #define SKYPAT_SYSTEMC_F(test_fixture, test_name) \ SKYPAT_SYSTEMC_TEST_CASE(test_fixture, test_name, skypat::Test) // Boolean assertions. #define EXPECT_TRUE(condition) \ SKYPAT_TEST_BOOLEAN(condition, #condition, false, true, \ SKYPAT_NONFATAL_FAILURE) #define EXPECT_FALSE(condition) \ SKYPAT_TEST_BOOLEAN(!(condition), #condition, true, false, \ SKYPAT_NONFATAL_FAILURE) #define ASSERT_TRUE(condition) \ SKYPAT_TEST_BOOLEAN(condition, #condition, false, true, \ SKYPAT_FATAL_FAILURE) #define ASSERT_FALSE(condition) \ SKYPAT_TEST_BOOLEAN(!(condition), #condition, true, false, \ SKYPAT_FATAL_FAILURE) // Boolean assertions. #define EXPECT_TRUE_MSG(condition, msg) \ SKYPAT_TEST_BOOLEAN(condition, #condition, false, true, \ SKYPAT_NONFATAL_FAILURE) << msg #define EXPECT_FALSE_MSG(condition, msg) \ SKYPAT_TEST_BOOLEAN(!(condition), #condition, true, false, \ SKYPAT_NONFATAL_FAILURE) << msg #define ASSERT_TRUE_MSG(condition, msg) \ SKYPAT_TEST_BOOLEAN(condition, #condition, false, true, \ SKYPAT_FATAL_FAILURE) << msg #define ASSERT_FALSE_MSG(condition, msg) \ SKYPAT_TEST_BOOLEAN(!(condition), #condition, true, false, \ SKYPAT_FATAL_FAILURE) << msg #define SKYPAT_EXPECT_PRED(condition, actual, expected) \ SKYPAT_TEST_PREDICATE(condition, #condition, \ actual, expected, \ SKYPAT_NONFATAL_FAILURE) #define SKYPAT_ASSERT_PRED(condition, actual, expected) \ SKYPAT_TEST_PREDICATE(condition, #condition, \ actual, expected, \ SKYPAT_FATAL_FAILURE) #define EXPECT_EQ(actual, expected) \ SKYPAT_EXPECT_PRED((actual == expected), actual, expected) #define EXPECT_NE(actual, expected) \ SKYPAT_EXPECT_PRED((actual != expected), actual, expected) #define EXPECT_LE(actual, expected) \ SKYPAT_EXPECT_PRED((actual <= expected), actual, expected) #define EXPECT_LT(actual, expected) \ SKYPAT_EXPECT_PRED((actual < expected), actual, expected) #define EXPECT_GE(actual, expected) \ SKYPAT_EXPECT_PRED((actual >= expected), actual, expected) #define EXPECT_GT(actual, expected) \ SKYPAT_EXPECT_PRED((actual > expected), actual, expected) #define ASSERT_EQ(actual, expected) \ SKYPAT_ASSERT_PRED((actual == expected), actual, expected) #define ASSERT_NE(actual, expected) \ SKYPAT_ASSERT_PRED((actual != expected), actual, expected) #define ASSERT_LE(actual, expected) \ SKYPAT_ASSERT_PRED((actual <= expected), actual, expected) #define ASSERT_LT(actual, expected) \ SKYPAT_ASSERT_PRED((actual < expected), actual, expected) #define ASSERT_GE(actual, expected) \ SKYPAT_ASSERT_PRED((actual >= expected), actual, expected) #define ASSERT_GT(actual, expected) \ SKYPAT_ASSERT_PRED((actual > expected), actual, expected) #define EXPECT_EQ_MSG(actual, expected, mesg) \ SKYPAT_EXPECT_PRED((actual == expected), actual, expected) << mesg #define EXPECT_NE_MSG(actual, expected, mesg) \ SKYPAT_EXPECT_PRED((actual != expected), actual, expected) << mesg #define EXPECT_LE_MSG(actual, expected, mesg) \ SKYPAT_EXPECT_PRED((actual <= expected), actual, expected) << mesg #define EXPECT_LT_MSG(actual, expected, mesg) \ SKYPAT_EXPECT_PRED((actual < expected), actual, expected) << mesg #define EXPECT_GE_MSG(actual, expected, mesg) \ SKYPAT_EXPECT_PRED((actual >= expected), actual, expected) << mesg #define EXPECT_GT_MSG(actual, expected, mesg) \ SKYPAT_EXPECT_PRED((actual > expected), actual, expected) << mesg #define ASSERT_EQ_MSG(actual, expected, mesg) \ SKYPAT_ASSERT_PRED((actual == expected), actual, expected) << mesg #define ASSERT_NE_MSG(actual, expected, mesg) \ SKYPAT_ASSERT_PRED((actual != expected), actual, expected) << mesg #define ASSERT_LE_MSG(actual, expected, mesg) \ SKYPAT_ASSERT_PRED((actual <= expected), actual, expected) << mesg #define ASSERT_LT_MSG(actual, expected, mesg) \ SKYPAT_ASSERT_PRED((actual < expected), actual, expected) << mesg #define ASSERT_GE_MSG(actual, expected, mesg) \ SKYPAT_ASSERT_PRED((actual >= expected), actual, expected) << mesg #define ASSERT_GT_MSG(actual, expected, mesg) \ SKYPAT_ASSERT_PRED((actual > expected), actual, expected) << mesg #define PERFORM(event) \ for (skypat::testing::PerfIterator __loop(__FILE__, __LINE__, event); \ __loop.hasNext(); \ __loop.next() ) } // namespace of skypat #endif SkyPat-3.2.0/lib/000077500000000000000000000000001465531052300135015ustar00rootroot00000000000000SkyPat-3.2.0/lib/.gitignore000066400000000000000000000000271465531052300154700ustar00rootroot00000000000000libskypat.la skypat.pc SkyPat-3.2.0/lib/ADT/000077500000000000000000000000001465531052300141115ustar00rootroot00000000000000SkyPat-3.2.0/lib/ADT/Color.cpp000066400000000000000000000023661465531052300157020ustar00rootroot00000000000000//===- Color.cpp ------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include using namespace skypat; //===----------------------------------------------------------------------===// // Color //===----------------------------------------------------------------------===// Color::Color(kColor pColor, kType pType) : m_Color(pColor), m_Type(pType) { } Color Color::Bold(kColor pColor) { return Color(pColor, BOLD); } Color Color::BackGround(kColor pColor) { return Color(pColor, BACKGROUND); } void Color::setColor(std::ostream& pOS) { pOS << "\033["; if (m_Color != RESET) { if (m_Type == BOLD) { pOS << "1;"; } // TODO: Turn off bold mode; int base_color = m_Type == BACKGROUND ? 40 : 30; pOS << (base_color + m_Color); } pOS << 'm'; } std::ostream& std::operator<<(std::ostream& pOS, Color pColor) { pColor.setColor(pOS); return pOS; } std::ostream& std::operator<<(std::ostream& pOS, Color::kColor pColor) { Color(pColor).setColor(pOS); return pOS; } SkyPat-3.2.0/lib/Core/000077500000000000000000000000001465531052300143715ustar00rootroot00000000000000SkyPat-3.2.0/lib/Core/Repeater.cpp000066400000000000000000000037241465531052300166520ustar00rootroot00000000000000//===- Repeater.cpp --------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include using namespace skypat; //===----------------------------------------------------------------------===// // Repeater //===----------------------------------------------------------------------===// testing::Repeater::Repeater() : m_bForward(true) { } testing::Repeater::~Repeater() { // Do nothing. Since we arn't the owner of Listeners. } void testing::Repeater::add(Listener* pListener) { if (NULL != pListener) { m_Listeners.push_back(pListener); } } void testing::Repeater::release(Listener& pListener) { ListenerList::iterator listener, lEnd = m_Listeners.end(); for (listener = m_Listeners.begin(); listener != lEnd; ++listener) { if (*listener == &pListener) { m_Listeners.erase(listener); return; } } } #define SKYPAT_REPEATER_METHOD(Name, ParamType) \ void testing::Repeater::Name(const ParamType& pParam) { \ if (m_bForward) { \ ListenerList::iterator listener, lEnd = m_Listeners.end(); \ for (listener = m_Listeners.begin(); listener != lEnd; ++listener) { \ (*listener)->Name(pParam); \ } \ } \ } SKYPAT_REPEATER_METHOD(OnTestProgramStart, testing::UnitTest) SKYPAT_REPEATER_METHOD(OnTestCaseStart, TestCase) SKYPAT_REPEATER_METHOD(OnSetUpStart, UnitTest) SKYPAT_REPEATER_METHOD(OnSetUpEnd, UnitTest) SKYPAT_REPEATER_METHOD(OnTestStart, TestInfo) SKYPAT_REPEATER_METHOD(OnTestPartResult, TestPartResult) SKYPAT_REPEATER_METHOD(OnPerfPartResult, PerfPartResult) SKYPAT_REPEATER_METHOD(OnTestEnd, TestInfo) SKYPAT_REPEATER_METHOD(OnTearDownStart, UnitTest) SKYPAT_REPEATER_METHOD(OnTearDownEnd, UnitTest) SKYPAT_REPEATER_METHOD(OnTestCaseEnd, TestCase) SKYPAT_REPEATER_METHOD(OnTestProgramEnd, UnitTest) SkyPat-3.2.0/lib/Core/Test.cpp000066400000000000000000000055421465531052300160220ustar00rootroot00000000000000//===- Test.cpp -----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include #include #include #include #include #include #include #include using namespace skypat; //===----------------------------------------------------------------------===// // Helper Functions //===----------------------------------------------------------------------===// static inline void help(const int& pArgc, char* pArgv[]) { testing::Log::getOStream() << "Usage:\n" << "\t" << pArgv[0] << " [options...]\n\n" << "Options:\n" << "\t-c [file] toutput CSV to [file]\n" << "\t-h Show this help manual\n"; } //===----------------------------------------------------------------------===// // Test //===----------------------------------------------------------------------===// Test::~Test() { // MUST KEEP THIS DESTRUCTOR } void Test::run() { this->TestBody(); } void Test::Initialize(const std::string& pProgName) { testing::UnitTest::self()->repeater().add(new PrettyResultPrinter()); if (!testing::UnitTest::self()->addRunCase(pProgName)) testing::UnitTest::self()->addAllRunCases(); } void Test::Initialize(const std::string& pProgName, const std::string& pCSVResult) { if (!pCSVResult.empty()) { CSVResultPrinter* printer = new CSVResultPrinter(); if (printer->open(pCSVResult)) { testing::UnitTest::self()->repeater().add(printer); } else { testing::Log::getOStream() << "Failed to open file `" << pCSVResult << "`\n"; delete printer; } } else testing::UnitTest::self()->repeater().add(new PrettyResultPrinter()); if (!testing::UnitTest::self()->addRunCase(pProgName)) testing::UnitTest::self()->addAllRunCases(); } void Test::Initialize(const int& pArgc, char* pArgv[]) { // Choose user's printer int opt; std::string csvFile; while ((opt = getopt(pArgc, pArgv, "c:h")) != -1 ) { switch (opt) { case 'c': csvFile = optarg; break; case 'h': default: help(pArgc, pArgv); return; } } // Choice runnable tests Path progname(pArgv[0]); progname = progname.filename(); Initialize(progname.native(), csvFile); } void Test::RunAll() { testing::UnitTest::self()->RunAll(); } void Test::Sleep(int pMS) { assert(pMS > 0 && "Cannot sleep zero milliseconds"); struct timespec ts = { pMS / 1000, (pMS % 1000) * 1000 * 1000 }; nanosleep(&ts, NULL); } SkyPat-3.2.0/lib/Core/UnitTest.cpp000066400000000000000000000056671465531052300166720ustar00rootroot00000000000000//===- UnitTest.cpp -------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include using namespace skypat; //===----------------------------------------------------------------------===// // Details of UnitTest //===----------------------------------------------------------------------===// testing::UnitTest::UnitTest() : m_pCurrentInfo(NULL), m_NumOfTests(0), m_NumOfFails(0) { } testing::UnitTest::~UnitTest() { CaseMap::iterator iCase, iEnd = m_CaseMap.end(); for (iCase = m_CaseMap.begin(); iCase != iEnd; ++iCase) { delete iCase->second; } } /// addRunCase - add the test case to run /// @return true if the case exists (be stored at static-time). bool testing::UnitTest::addRunCase(const std::string& pCaseName) { CaseMap::iterator iCase = m_CaseMap.find(pCaseName); if (m_CaseMap.end() == iCase) return false; m_RunCases.push_back(iCase->second); return true; } /// addAllRunCase - add all test cases to run void testing::UnitTest::addAllRunCases() { CaseMap::iterator iCase, iEnd = m_CaseMap.end(); for (iCase = m_CaseMap.begin(); iCase != iEnd; ++iCase) { m_RunCases.push_back(iCase->second); } } testing::TestInfo* testing::UnitTest::addTestInfo(const std::string& pCaseName, const std::string& pTestName, testing::TestFactoryBase& pFactory) { CaseMap::iterator iCase = m_CaseMap.find(pCaseName); TestCase* test_case; if (iCase != m_CaseMap.end()) test_case = iCase->second; else { test_case = new TestCase(pCaseName); m_CaseMap.insert(make_pair(pCaseName, test_case)); } testing::TestInfo* info = test_case->addTestInfo(pTestName, pFactory); ++m_NumOfTests; return info; } void testing::UnitTest::addTestPartResult(const TestPartResult& pPartResult) { m_pCurrentInfo->addTestPartResult(pPartResult); m_Repeater.OnTestPartResult(pPartResult); if (testing::TestPartResult::kSuccess != pPartResult.type()) ++m_NumOfFails; } testing::PerfPartResult* testing::UnitTest::addPerfPartResult(const char* pFile, int pLine) { /* XXX: */ m_Repeater.OnPerfPartResult(testing::PerfPartResult(pFile, pLine)); return m_pCurrentInfo->addPerfPartResult(pFile, pLine); } void testing::UnitTest::RunAll() { m_Repeater.OnTestProgramStart(*this); RunCases::iterator iCase, iEnd = m_RunCases.end(); for (iCase = m_RunCases.begin(); iCase != iEnd; ++iCase) { TestCase* test_case = *iCase; m_Repeater.OnTestCaseStart(*test_case); TestCase::iterator it = test_case->begin(); TestCase::iterator iEnd = test_case->end(); while (it != iEnd) { m_pCurrentInfo = *it; (*it)->run(); ++it; } m_Repeater.OnTestCaseEnd(*test_case); } m_Repeater.OnTestProgramEnd(*this); } SkyPat-3.2.0/lib/Listeners/000077500000000000000000000000001465531052300154515ustar00rootroot00000000000000SkyPat-3.2.0/lib/Listeners/CSVResultPrinter.cpp000066400000000000000000000030611465531052300213530ustar00rootroot00000000000000//===- CSVResultPrinter.cpp -----------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include #include using namespace skypat; //===----------------------------------------------------------------------===// // CSVResultPrinter //===----------------------------------------------------------------------===// CSVResultPrinter::CSVResultPrinter() : m_OStream() { } CSVResultPrinter::~CSVResultPrinter() { if (m_OStream.is_open()) m_OStream.close(); } bool CSVResultPrinter::open(const std::string& pFileName) { if (m_OStream.is_open()) return false; m_OStream.open(pFileName.c_str(), std::ostream::out | std::ostream::app); return m_OStream.good(); } void CSVResultPrinter::OnTestEnd(const testing::TestInfo& pTestInfo) { if (!pTestInfo.result().performance().empty()) { testing::TestResult::Performance::const_iterator perf = pTestInfo.result().performance().begin(); testing::TestResult::Performance::const_iterator pEnd = pTestInfo.result().performance().end(); m_OStream << pTestInfo.getTestName() << ","; while (perf != pEnd) { m_OStream << (*perf)->getTimerNum(); ++perf; if (perf != pEnd) m_OStream << ","; } m_OStream << std::endl; } } SkyPat-3.2.0/lib/Listeners/PrettyResultPrinter.cpp000066400000000000000000000155271465531052300222210ustar00rootroot00000000000000//===- PrettyResultPrinter.cpp ---------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include #include using namespace skypat; //===----------------------------------------------------------------------===// // PrettyResultPrinter //===----------------------------------------------------------------------===// void PrettyResultPrinter::PrintCaseName(const std::string& pCase, const std::string& pTest) { testing::Log::getOStream() << pCase << "." << pTest; } void PrettyResultPrinter::OnTestProgramStart(const testing::UnitTest& pUnitTest) { testing::Log::getOStream() << Color::CYAN << "[ skypat ] " << "Running " << pUnitTest.getNumOfTests() << " tests from " << pUnitTest.getNumOfCases() << " cases." << std::endl; } void PrettyResultPrinter::OnTestCaseStart(const testing::TestCase& pTestCase) { testing::Log::getOStream() << Color::GREEN << "[----------] " << Color::YELLOW; int num_tests = pTestCase.getNumOfTests(); if (1 == num_tests) testing::Log::getOStream() << "1 test from "; else if (1 < num_tests) testing::Log::getOStream() << num_tests << " tests from "; testing::Log::getOStream() << pTestCase.getCaseName() << "." << Color::RESET << std::endl; } void PrettyResultPrinter::OnTestStart(const testing::TestInfo& pTestInfo) { testing::Log::getOStream() << Color::GREEN << "[ RUN ] " << Color::WHITE; PrintCaseName(pTestInfo.getCaseName(), pTestInfo.getTestName()); testing::Log::getOStream() << Color::RESET << std::endl; } void PrettyResultPrinter::OnTestEnd(const testing::TestInfo& pTestInfo) { // unit-test results if (pTestInfo.result().isPassed()) { testing::Log::getOStream() << Color::GREEN << "[ OK ] \n"; } if (pTestInfo.result().isFailed()) { testing::Log::getOStream() << Color::RED << "[ FAILED ] "; testing::TestResult::Reliability::const_iterator test = pTestInfo.result().reliability().begin(); testing::TestResult::Reliability::const_iterator tEnd = pTestInfo.result().reliability().end(); while (test != tEnd) { testing::Log::getOStream() << "\n" << Color::Bold(Color::YELLOW) << (*test)->filename() << ':' << (*test)->lineNumber() << ": "; switch ((*test)->type()) { case testing::TestPartResult::kFatalFailure: { testing::Log::getOStream() << Color::RED << "fatal: " << Color::RESET << Color::Bold(Color::YELLOW) << "failed to assert\n"; break; } case testing::TestPartResult::kNonFatalFailure: { testing::Log::getOStream() << Color::MAGENTA << "error: " << Color::RESET << Color::Bold(Color::YELLOW) << "failed to expect\n"; break; } default: break; } testing::Log::getOStream() << Color::RESET << (*test)->message(); ++test; } testing::Log::getOStream() << std::endl; } // performance test results if (!pTestInfo.result().performance().empty()) { // timer's result testing::Log::getOStream() << Color::Bold(Color::BLUE) << "[ TIME (ns)]"; testing::TestResult::Performance::const_iterator perf = pTestInfo.result().performance().begin(); testing::TestResult::Performance::const_iterator pEnd = pTestInfo.result().performance().end(); while (perf != pEnd) { testing::Log::getOStream() << " " << std::setw(12) << (*perf)->getTimerNum(); ++perf; } testing::Log::getOStream() << Color::RESET << std::endl; // perf_event's types testing::Log::getOStream() << Color::Bold(Color::BLUE) << "[EVENT TYPE]"; perf = pTestInfo.result().performance().begin(); pEnd = pTestInfo.result().performance().end(); while (perf != pEnd) { testing::Log::getOStream() << " [" << std::setw(10) << skypat::Perf_event_name[(*perf)->getPerfEventType()] << "]"; ++perf; } testing::Log::getOStream() << Color::RESET << std::endl; // perf_event's results testing::Log::getOStream() << Color::Bold(Color::BLUE) << "[RESULT NUM]"; perf = pTestInfo.result().performance().begin(); pEnd = pTestInfo.result().performance().end(); while (perf != pEnd) { testing::Log::getOStream() << " " << std::setw(12) << (*perf)->getPerfEventNum(); ++perf; } testing::Log::getOStream() << Color::RESET << std::endl; } } void PrettyResultPrinter::OnTestProgramEnd(const testing::UnitTest& pUnitTest) { testing::Log::getOStream() << Color::CYAN << "[==========] " << pUnitTest.getNumOfTests(); if (1 == pUnitTest.getNumOfTests()) testing::Log::getOStream() << " test from "; if (1 < pUnitTest.getNumOfTests()) testing::Log::getOStream() << " tests from "; testing::Log::getOStream() << pUnitTest.getNumOfCases() << " cases ran.\n"; if (0 == pUnitTest.getNumOfFails()) { testing::Log::getOStream() << Color::GREEN << "[ PASSED ] " << Color::RESET << pUnitTest.getNumOfTests(); if (1 == pUnitTest.getNumOfTests()) { testing::Log::getOStream() << " test.\n" << std::flush; } if (1 < pUnitTest.getNumOfTests()) { testing::Log::getOStream() << " tests.\n" << std::flush; } } else { testing::Log::getOStream() << Color::RED << "[ FAILED ] " << Color::RESET << pUnitTest.getNumOfFails(); if (1 == pUnitTest.getNumOfFails()) { testing::Log::getOStream() << " test.\n" << std::flush; } if (1 < pUnitTest.getNumOfFails()) { testing::Log::getOStream() << " tests.\n" << std::flush; } } } SkyPat-3.2.0/lib/Makefile.am000066400000000000000000000026021465531052300155350ustar00rootroot00000000000000SOURCE = skypat.cpp \ ADT/Color.cpp \ Support/ManagedStatic.cpp \ Support/Timer.cpp \ Support/Unix/Timer.inc \ Support/Path.cpp \ Support/Perf.cpp \ Support/Unix/Path.inc \ Support/Unix/Perf.inc \ Listeners/PrettyResultPrinter.cpp \ Listeners/CSVResultPrinter.cpp \ Core/Test.cpp \ Core/Repeater.cpp \ Core/UnitTest.cpp \ Thread/Thread.cpp \ Thread/ThreadImpl.cpp \ Thread/Mutex.cpp \ Thread/Pthread/Mutex.inc ANDROID_CPPFLAGS=-fno-rtti -fno-exceptions -Waddress -Wchar-subscripts -Wcomment -Wformat -Wparentheses -Wreorder -Wreturn-type -Wsequence-point -Wstrict-aliasing -Wstrict-overflow=1 -Wswitch -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunused-function -Wunused-label -Wunused-value -Wunused-variable -Wvolatile-register-var SKYPAT_INCLUDES = -I${abs_top_srcdir}/include \ -I${abs_top_builddir}/include if ENABLE_OPTIMIZE SKYPAT_CPPFLAGS = -O2 -std=c++11 else SKYPAT_CPPFLAGS = -g -std=c++11 endif AM_CPPFLAGS = ${SKYPAT_INCLUDES} ${SKYPAT_CPPFLAGS} ${ANDROID_CPPFLAGS} ############################# # Build shared library lib_LTLIBRARIES = libskypat.la libskypat_la_SOURCES = ${SOURCE} libskypat_la_LDFLAGS = -version-info @SKYPAT_VERSION@ if HAVE_PTHREADS libskypat_la_LDFLAGS += -lpthread endif pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = skypat.pc # Remove temporary *.la files install-exec-hook: rm -f $(DESTDIR)$(libdir)/libskypat.la SkyPat-3.2.0/lib/Support/000077500000000000000000000000001465531052300151555ustar00rootroot00000000000000SkyPat-3.2.0/lib/Support/ManagedStatic.cpp000066400000000000000000000031701465531052300203660ustar00rootroot00000000000000//===- ManagedStatic.h -----------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include using namespace skypat; static const ManagedStaticBase *StaticList = NULL; //===----------------------------------------------------------------------===// // ManagedStaticBase //===----------------------------------------------------------------------===// void ManagedStaticBase::RegisterManagedStatic(void *(*pCreator)(), void (*pDeleter)(void*)) const { assert(NULL == m_Ptr && NULL == m_pDeleter && m_pNext == 0 && "Partially initialized ManagedStatic!?"); m_Ptr = pCreator ? pCreator() : NULL; m_pDeleter = pDeleter; // Add to list of managed statics. m_pNext = StaticList; StaticList = this; } void ManagedStaticBase::destroy() const { assert(m_pDeleter && "ManagedStatic not initialized correctly!"); assert(StaticList == this && "Not destroyed in reverse order of construction?"); // Unlink from list. StaticList = m_pNext; m_pNext = NULL; // Destroy memory. m_pDeleter(m_Ptr); // Cleanup. m_Ptr = NULL; m_pDeleter = NULL; } //===----------------------------------------------------------------------===// // Non-member functions //===----------------------------------------------------------------------===// void skypat::shutdown() { while (StaticList) StaticList->destroy(); } SkyPat-3.2.0/lib/Support/Path.cpp000066400000000000000000000115101465531052300165530ustar00rootroot00000000000000//===- Path.cpp -----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include #include #include // Include the truly platform-specific parts. #if defined(SKYPAT_ON_UNIX) #include "Unix/Path.inc" #endif #if defined(SKYPAT_ON_WIN32) #include "Windows/Path.inc" #endif #if defined(SKYPAT_ON_DRAGON) #include "Dragon/Path.inc" #endif using namespace skypat; const char Path::colon = ':'; const char Path::dot = '.'; //===--------------------------------------------------------------------===// // Path //===--------------------------------------------------------------------===// Path::Path() : m_PathName() { } Path::Path(const Path::ValueType* pStr) : m_PathName() { if (NULL != pStr) m_PathName = pStr; } Path::Path(const Path::StringType &s ) : m_PathName(s) { } Path::Path(const Path& pCopy) : m_PathName(pCopy.m_PathName) { } Path::~Path() { } bool Path::isFromRoot() const { if (m_PathName.empty()) return false; return (separator == m_PathName[0]); } bool Path::isFromPWD() const { if (2 > m_PathName.size()) return false; return ('.' == m_PathName[0] && separator == m_PathName[1]); } int Path::compare(const char* pString) const { return ::strcmp(pString, m_PathName.c_str()); } Path& Path::assign(const Path::StringType &s) { m_PathName.assign(s); return *this; } Path& Path::assign(const Path::ValueType* s, unsigned int length) { if (0 == s || 0 == length) assert(0 && "assign a null or empty string to Path"); m_PathName.assign(s, length); return *this; } //a,/b a/,b a/,b/ a,b is a/b Path& Path::append(const Path& pPath) { //first path is a/,second path is /b if(m_PathName[m_PathName.length()-1] == separator && pPath.native()[0] == separator) { unsigned int old_size = m_PathName.size()-1; unsigned int new_size = old_size + pPath.native().size(); m_PathName.resize(new_size); strcpy(const_cast(m_PathName.data()+old_size), pPath.native().data()); } //first path is a,second path is b else if(this->native()[this->native().size()-1] != separator && pPath.native()[0] != separator) { m_PathName.append(separator_str); m_PathName.append(pPath.native()); } // a/,b or a,/b just append else { m_PathName.append(pPath.native()); } return *this; } bool Path::empty() const { return m_PathName.empty(); } Path::StringType Path::generic_string() const { StringType result = m_PathName; sys::canonicalize(result); return result; } bool Path::canonicalize() { return sys::canonicalize(m_PathName); } Path::StringType::size_type Path::AppendSeparatorAsNeeded() { #if defined(SKYMIZER_ON_WIN32) // On Windows platform, path can not append separator. return 0; #endif StringType::value_type last_char = m_PathName[m_PathName.size() - 1]; if (!m_PathName.empty() && !sys::is_separator(last_char)) { StringType::size_type tmp(m_PathName.size()); m_PathName += separator_str; return tmp; } return 0; } void Path::EraseRedundantSeparator(Path::StringType::size_type pSepPos) { size_t begin=pSepPos; // skip '/' or '\\' while(separator == m_PathName[pSepPos]) { #if defined(SKYMIZER_ON_WIN32) pSepPos += 2; #else ++pSepPos; #endif } if(begin!=pSepPos) m_PathName.erase(begin+1,pSepPos-begin-1); } Path Path::parent_path() const { size_t end_pos = m_PathName.find_last_of(separator); if (end_pos != StringType::npos) return Path(m_PathName.substr(0, end_pos)); return Path(); } Path Path::filename() const { size_t pos = m_PathName.find_last_of(separator); if (pos != StringType::npos) { ++pos; return Path(m_PathName.substr(pos)); } return Path(*this); } Path Path::stem() const { size_t begin_pos = m_PathName.find_last_of(separator)+1; size_t end_pos = m_PathName.find_last_of(dot); Path result_path(m_PathName.substr(begin_pos, end_pos - begin_pos)); return result_path; } Path Path::extension() const { size_t begin_pos = m_PathName.find_last_of('.'); Path result_path(m_PathName.substr(begin_pos)); return result_path; } //===--------------------------------------------------------------------===// // non-member functions //===--------------------------------------------------------------------===// bool skypat::operator==(const Path& pLHS,const Path& pRHS) { return (pLHS.generic_string()==pRHS.generic_string()); } bool skypat::operator!=(const Path& pLHS,const Path& pRHS) { return !(pLHS==pRHS); } Path skypat::operator+(const Path& pLHS, const Path& pRHS) { Path result = pLHS; result.append(pRHS); return result; } SkyPat-3.2.0/lib/Support/Perf.cpp000066400000000000000000000013401465531052300165530ustar00rootroot00000000000000//===- Perf.cpp ----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include //===----------------------------------------------------------------------===// // Perf Implementation //===----------------------------------------------------------------------===// #if defined(SKYPAT_ON_WIN32) #include "Windows/Perf.inc" #endif #if defined(SKYPAT_ON_UNIX) #include "Unix/Perf.inc" #endif #if defined(SKYPAT_ON_DRAGON) #include "Dragon/Perf.inc" #endif SkyPat-3.2.0/lib/Support/Timer.cpp000066400000000000000000000013461465531052300167450ustar00rootroot00000000000000//===- Timer.cpp ----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include //===----------------------------------------------------------------------===// // Timer Implementation //===----------------------------------------------------------------------===// #if defined(SKYPAT_ON_WIN32) #include "Windows/Timer.inc" #endif #if defined(SKYPAT_ON_UNIX) #include "Unix/Timer.inc" #endif #if defined(SKYPAT_ON_DRAGON) #include "Dragon/Timer.inc" #endif SkyPat-3.2.0/lib/Support/Unix/000077500000000000000000000000001465531052300161005ustar00rootroot00000000000000SkyPat-3.2.0/lib/Support/Unix/Path.inc000066400000000000000000000074511465531052300174760ustar00rootroot00000000000000//===- Path.inc -----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include namespace skypat { const char Path::separator = '/'; const char Path::preferred_separator = '/'; const Path::StringType Path::separator_str = Path::StringType("/"); namespace sys { // return the last charactor being handled. size_t canonicalize(std::string& pathname) { // Variable Index // // SepTable - stack of result separators // LR(1) Algorithm // // traverse pPathName // if we meet '//', '///', '////', ... // -> ignore it // -> push current into stack // -> jump to the next not '/' // if we meet '/./' // -> ignore // -> jump to the next not '/' // if we meet '/../' // -> pop previous position of '/' P // -> erase P+1 to now // if we meet other else // -> go go go // if we meet '/.../', '/..../', ... -> illegal if (pathname.empty()) return 0; size_t handler = 0; std::stack slash_stack; slash_stack.push(-1); while (handler < pathname.size()) { if (Path::separator == pathname[handler]) { // handler = 1st '/' size_t next = handler + 1; if (next >= pathname.size()) return handler; switch(pathname[next]) { // next = handler + 1; case Path::separator: { // '//' while (next < pathname.size() && Path::separator == pathname[next]) ++next; // next is the last not '/' pathname.erase(handler, next - handler - 1); // handler is the first '/' slash_stack.push(handler); break; } case '.': { // '/.' ++next; // next = handler + 2 if (next >= pathname.size()) // '/.' return handler; switch (pathname[next]) { case Path::separator: { // '/./' pathname.erase(handler, 2); break; } case '.': { // '/..' ++next; // next = handler + 3; if (next >= pathname.size()) // '/..?' return handler; switch(pathname[next]) { case Path::separator: { // '/../' handler = slash_stack.top(); slash_stack.pop(); pathname.erase(handler+1, next-handler); if (static_cast(-1) == handler) { slash_stack.push(-1); handler = pathname.find_first_of(Path::separator, handler); } break; } case '.': { // '/...', illegal return handler; break; } default : { // '/..a' slash_stack.push(handler); handler = pathname.find_first_of(Path::separator, handler+3); break; } } break; } default : { // '/.a' slash_stack.push(handler); handler = pathname.find_first_of(Path::separator, handler+2); break; } } break; } default : { // '/a slash_stack.push(handler); handler = pathname.find_first_of(Path::separator, handler+1); break; } } } else { handler = pathname.find_first_of(Path::separator, handler); } } return handler; } /// Checks if \ref pValue is the separator of the path in the system. bool is_separator(char value) { return (value == Path::separator); } } // namespace of sys } // namespace of skypat SkyPat-3.2.0/lib/Support/Unix/Perf.inc000066400000000000000000000100241465531052300174640ustar00rootroot00000000000000//===- Perf.inc ----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include #include #include #if defined(HAVE_LINUX_PERF_EVENT_H) #include #include #include #include #if defined(HAVE_ASM_UNISTD_H) #include #endif #endif #ifndef SKYPAT_SKYPAT_H #include #endif namespace skypat { namespace testing { namespace internal { //===----------------------------------------------------------------------===// // Perf Implementation //===----------------------------------------------------------------------===// class PerfImpl { public: PerfImpl() { } ~PerfImpl() { #if defined(HAVE_LINUX_PERF_EVENT_H) close(m_Fd); #endif } testing::Interval getCounter() { #if defined(HAVE_LINUX_PERF_EVENT_H) unsigned long long counter; read(m_Fd, &counter, sizeof(unsigned long long)); return counter; #else return 0; #endif return -1; } void init(enum PerfEvent pEvent) { #if defined(HAVE_LINUX_PERF_EVENT_H) /* store the perf event numbers with the same order of skypat:Perf_event_name */ static const decltype(perf_event_attr::config) event_list[] = { PERF_COUNT_HW_CPU_CYCLES, PERF_COUNT_HW_INSTRUCTIONS, PERF_COUNT_HW_CACHE_REFERENCES, PERF_COUNT_HW_CACHE_MISSES, PERF_COUNT_HW_BRANCH_INSTRUCTIONS, PERF_COUNT_HW_BRANCH_MISSES, PERF_COUNT_HW_BUS_CYCLES, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, PERF_COUNT_HW_STALLED_CYCLES_BACKEND, PERF_COUNT_HW_REF_CPU_CYCLES, PERF_COUNT_SW_CPU_CLOCK, PERF_COUNT_SW_TASK_CLOCK, PERF_COUNT_SW_PAGE_FAULTS, PERF_COUNT_SW_CONTEXT_SWITCHES, PERF_COUNT_SW_CPU_MIGRATIONS, PERF_COUNT_SW_PAGE_FAULTS_MIN, PERF_COUNT_SW_PAGE_FAULTS_MAJ, PERF_COUNT_SW_ALIGNMENT_FAULTS, PERF_COUNT_SW_EMULATION_FAULTS, #ifdef PERF_COUNT_SW_DUMMY PERF_COUNT_SW_DUMMY #else 0 #endif }; struct perf_event_attr attr; memset(&attr, 0, sizeof(attr)); attr.inherit = 1; attr.disabled = 1; attr.config = event_list[pEvent]; if(pEvent < PerfEvent::CPU_CLOCK) attr.type = PERF_TYPE_HARDWARE; else attr.type = PERF_TYPE_SOFTWARE; attr.size = sizeof(attr); m_Fd = syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0); #endif } void start() { #if defined(HAVE_LINUX_PERF_EVENT_H) ioctl(m_Fd, PERF_EVENT_IOC_ENABLE); #endif m_Start = getCounter(); assert(-1 != m_Start && "fail to get performance counters"); } void stop() { #if defined(HAVE_LINUX_PERF_EVENT_H) ioctl(m_Fd, PERF_EVENT_IOC_DISABLE); #endif m_End = getCounter(); assert(-1 != m_End && "fail to get performance counters"); } testing::Interval getValue() const { return (m_End - m_Start); } private: testing::Interval m_Start; testing::Interval m_End; static long g_ClkTick; int m_Fd; }; long PerfImpl::g_ClkTick = -1; static ManagedStatic g_Perf; //===----------------------------------------------------------------------===// // Perf //===----------------------------------------------------------------------===// Perf::Perf() : m_Interval(0), m_EventType(PerfEvent::CONTEXT_SWITCHES), m_bIsActive(false) { g_Perf->init(PerfEvent::CONTEXT_SWITCHES); g_Perf->start(); } Perf::Perf(enum PerfEvent pEvent) : m_Interval(0), m_EventType(pEvent), m_bIsActive(false) { g_Perf->init(pEvent); g_Perf->start(); } Perf::~Perf() { g_Perf->stop(); } void Perf::start() { m_Interval = g_Perf->getValue(); m_bIsActive = true; } void Perf::stop() { m_Interval = g_Perf->getValue() - m_Interval; m_bIsActive = false; } std::string Perf::unit() { return "times"; } } // namespace of internal } // namespace of testing } // namespace of skypat SkyPat-3.2.0/lib/Support/Unix/Timer.inc000066400000000000000000000067211465531052300176610ustar00rootroot00000000000000//===- Timer.inc ----------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include #include #include #include #if defined(HAVE_SYS_TIMES_H) #include #endif #if defined(HAVE_SYS_TIME_H) && defined(ENABLE_GETTIMEOFDAY) #include #endif #if defined(HAVE_LINUX_PERF_EVENT_H) #include #include #include #include #if defined(HAVE_ASM_UNISTD_H) #include #endif #endif namespace skypat { namespace testing { namespace internal { //===----------------------------------------------------------------------===// // Timer Implementation //===----------------------------------------------------------------------===// class TimerImpl { public: TimerImpl() { if (-1 == g_ClkTick) { g_ClkTick = sysconf(_SC_CLK_TCK); assert((0 < g_ClkTick) && "sysconf error"); #if defined(HAVE_LINUX_PERF_EVENT_H) struct perf_event_attr attr; memset(&attr, 0, sizeof(attr)); attr.inherit = 1; attr.disabled = 1; attr.type = PERF_TYPE_SOFTWARE; attr.config = PERF_COUNT_SW_TASK_CLOCK; attr.size = sizeof(attr); m_Fd = syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0); #endif } } ~TimerImpl() { #if defined(HAVE_LINUX_PERF_EVENT_H) ioctl(m_Fd, PERF_EVENT_IOC_DISABLE); close(m_Fd); #endif } testing::Interval clock() { #if defined(HAVE_LINUX_PERF_EVENT_H) unsigned long long runtime; read(m_Fd, &runtime, sizeof(unsigned long long)); return runtime; #elif defined(HAVE_CLOCK_GETTIME) && defined(ENABLE_CLOCK_GETTIME) struct timespec ts; int r = clock_gettime(CLOCK_MONOTONIC, &ts); return r == -1 ? -1 : ts.tv_sec * 1000000000LL + ts.tv_nsec; #elif defined(HAVE_GETTIMEOFDAY) && defined(ENABLE_GETTIMEOFDAY) struct timeval tv; int r = gettimeofday(&tv, NULL); return r == -1 ? -1 : tv.tv_sec * 1000000000LL + (tv.tv_usec * 1000LL); #else struct tms tm; clock_t r = times(&tm); return r == -1 ? -1 : r * 1000000000LL / g_ClkTick; #endif } void start() { if (false == g_bIsEnabled) { #if defined(HAVE_LINUX_PERF_EVENT_H) ioctl(m_Fd, PERF_EVENT_IOC_ENABLE); #endif g_bIsEnabled = true; m_Start = clock(); assert(-1 != m_Start && "fail to get starting time"); } } void stop() { m_End = clock(); assert(-1 != m_End && "fail to get elapsed time"); } private: testing::Interval m_Start; testing::Interval m_End; static bool g_bIsEnabled; static long g_ClkTick; int m_Fd; }; long TimerImpl::g_ClkTick = -1; bool TimerImpl::g_bIsEnabled = false; static ManagedStatic g_Timer; //===----------------------------------------------------------------------===// // Timer //===----------------------------------------------------------------------===// Timer::Timer() : m_Interval(0), m_bIsActive(false) { } Timer::~Timer() { } void Timer::start() { g_Timer->start(); m_Interval = g_Timer->clock(); m_bIsActive = true; } void Timer::stop() { m_Interval = g_Timer->clock() - m_Interval; m_bIsActive = false; } std::string Timer::unit() { return "ns"; } } // namespace of internal } // namespace of testing } // namespace of skypat SkyPat-3.2.0/lib/Thread/000077500000000000000000000000001465531052300147105ustar00rootroot00000000000000SkyPat-3.2.0/lib/Thread/Mutex.cpp000066400000000000000000000011661465531052300165220ustar00rootroot00000000000000//===- Mutex.cpp ----------------------------------------------------------===// // // The SkyPat team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include #include using namespace skypat; // Include the truly platform-specific parts. // *.inc defines MutexData and platform-specific mutex. #if defined(HAVE_PTHREAD) #include "Pthread/Mutex.inc" #else #include "Quick/Mutex.inc" #endif SkyPat-3.2.0/lib/Thread/Pthread/000077500000000000000000000000001465531052300162775ustar00rootroot00000000000000SkyPat-3.2.0/lib/Thread/Pthread/Mutex.inc000066400000000000000000000024421465531052300200760ustar00rootroot00000000000000//===- Mutex.inc ----------------------------------------------------------===// // // The SkyPat team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include #include #include //===----------------------------------------------------------------------===// // Mutex //===----------------------------------------------------------------------===// Mutex::Mutex() : m_pData(new MutexData()) { int code = pthread_mutex_init(&m_pData->mutex, NULL); if (0 != code) std::cerr<< code; } Mutex::~Mutex() { int code = pthread_mutex_destroy(&m_pData->mutex); if (0 != code) std::cerr<< code; delete m_pData; } void Mutex::lock() throw() { int code = pthread_mutex_lock(&m_pData->mutex); if (0 != code) std::cerr<< code; } void Mutex::unlock() throw() { int code = pthread_mutex_unlock(&m_pData->mutex); if (0 != code) std::cerr<< code; } Mutex::Status Mutex::tryLock() { switch(pthread_mutex_trylock(&m_pData->mutex)) { case 0: return Success; case EBUSY: return Busy; case EINVAL: return Invalid; } return UnknownError; } SkyPat-3.2.0/lib/Thread/Pthread/Thread.inc000066400000000000000000000021641465531052300202040ustar00rootroot00000000000000//===- Thread.inc ---------------------------------------------------------===// // // The SkyPat team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include //===----------------------------------------------------------------------===// // Thread //===----------------------------------------------------------------------===// void Thread::start() { pthread_attr_t attr; pthread_attr_init(&attr); // TODO: set up attributes // create a thread int code = pthread_create(&m_pThreadImpl->thread_id, &attr, ThreadImpl::start, this); if (0 != code) { std::cerr << code; } pthread_attr_destroy(&attr); } bool Thread::join() { // TODO: can not wait on itself // TODO: if the thread is finished or not running, then return false // TODO: pthread_join, then return code. void* status; int code = pthread_join(impl()->thread_id, &status); if (0 != code) { std::cerr << code; return false; } return true; } SkyPat-3.2.0/lib/Thread/Pthread/ThreadImpl.inc000066400000000000000000000040541465531052300210260ustar00rootroot00000000000000//===- ThreadImpl.cpp -----------------------------------------------------===// // // The SkyPat team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include //===----------------------------------------------------------------------===// // Thread-local storage //===----------------------------------------------------------------------===// static pthread_once_t per_thread_once = PTHREAD_ONCE_INIT; static pthread_key_t per_thread_key; static void thread_key_create() { pthread_key_create(&per_thread_key, NULL); } //===----------------------------------------------------------------------===// // ThreadData //===----------------------------------------------------------------------===// ThreadData::ThreadData() : thread(NULL) { } ThreadData::~ThreadData() { // avoid from deleting a uninitial key pthread_once(&per_thread_once, thread_key_create); pthread_key_delete(per_thread_key); } ThreadData* ThreadData::current() { // create the key of thread-local-storage if we never create the key before. pthread_once(&per_thread_once, thread_key_create); ThreadData* data = reinterpret_cast(pthread_getspecific(per_thread_key)); if (NULL == data) { data = new ThreadData(); pthread_setspecific(per_thread_key, data); } return data; } #include using namespace std; //===----------------------------------------------------------------------===// // ThreadImpl - Leverage system pthread //===----------------------------------------------------------------------===// void* ThreadImpl::start(void* pArg) { pthread_cleanup_push(ThreadImpl::finish, pArg); Thread* thread = reinterpret_cast(pArg); ThreadData::SetUp(thread->impl()->data, *thread->impl()->parent); thread->impl()->thread_id = pthread_self(); cerr << "(" << endl; thread->run(); cerr << ")" << endl; pthread_cleanup_pop(1); return 0; } SkyPat-3.2.0/lib/Thread/Quick/000077500000000000000000000000001465531052300157645ustar00rootroot00000000000000SkyPat-3.2.0/lib/Thread/Quick/ThreadImpl.inc000066400000000000000000000010631465531052300205100ustar00rootroot00000000000000//===- QThreadImpl.cpp ----------------------------------------------------===// // // The SkyPat team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include using namespace skymizer; //===----------------------------------------------------------------------===// // QThreadImpl - Quick Thread //===----------------------------------------------------------------------===// SkyPat-3.2.0/lib/Thread/Thread.cpp000066400000000000000000000026761465531052300166360ustar00rootroot00000000000000//===- Thread.cpp ---------------------------------------------------------===// // // The SkyPat team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include #include #include using namespace skypat; //===----------------------------------------------------------------------===// // Thread //===----------------------------------------------------------------------===// Thread::Thread() : m_pThreadImpl(new ThreadImpl(this)) { } Thread::~Thread() { delete m_pThreadImpl; } HANDLE Thread::getThreadID() const { return (HANDLE)impl()->thread_id; } const ThreadData* Thread::data() const { assert(NULL != m_pThreadImpl->data && "There is no thread data before creating a thread"); return m_pThreadImpl->data; } ThreadData* Thread::data() { assert(NULL != m_pThreadImpl->data && "There is no thread data before creating a thread"); return m_pThreadImpl->data; } const ThreadImpl* Thread::impl() const { return m_pThreadImpl; } ThreadImpl* Thread::impl() { return m_pThreadImpl; } // Include the truly platform-specific parts. // *.inc defines platform-specific implementation. #if defined(HAVE_PTHREAD) #include "Pthread/Thread.inc" #else #include "Quick/Thread.inc" #endif SkyPat-3.2.0/lib/Thread/ThreadImpl.cpp000066400000000000000000000022761465531052300174540ustar00rootroot00000000000000//===- ThreadImpl.cpp -----------------------------------------------------===// // // The SkyPat team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include using namespace skypat; //===----------------------------------------------------------------------===// // ThreadData //===----------------------------------------------------------------------===// void ThreadData::SetUp(ThreadData*& pData, Thread& pParent) { if (NULL != pData) return; pData = ThreadData::current(); pData->thread = &pParent; } //===----------------------------------------------------------------------===// // ThreadImpl //===----------------------------------------------------------------------===// ThreadImpl::ThreadImpl(Thread* pParent) : data(NULL), parent(pParent) { } ThreadImpl::~ThreadImpl() { } void ThreadImpl::finish(void* pArg) { } // Include the truly platform-specific parts. #if defined(HAVE_PTHREAD) #include "Pthread/ThreadImpl.inc" #else #include "Quick/ThreadImpl.inc" #endif SkyPat-3.2.0/lib/skypat.cpp000066400000000000000000000276331465531052300155330ustar00rootroot00000000000000//===- skypat.cpp ---------------------------------------------------------===// // // The SkyPat Team // // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace skypat; /* Define the numebr of iteration of performance loop */ #define SKYPAT_PERFORM_LOOP_TIMES 1 namespace skypat{ /* Establish perf event string array */ char const *Perf_event_name[] = { "CPU CYCLES", "INST NUM", "CACHE REF", "CACHE MISS", "BR INST", "BR MISSES", "BUS CYCLES", "STALLFRONT", "STALL BACK", "REF CYCLES", "CPU CLOCK", "TASK CLOCK", "PAGEFAULTS", "CTX SWITCH", "CPUMIGRATE", "PG FAULT m", "PG FAULT M", "ALIGNFAULT", "EMU FAULT", "D U M M Y " }; } // namespace of skypat //===----------------------------------------------------------------------===// // Non-member function //===----------------------------------------------------------------------===// testing::TestInfo* testing::MakeAndRegisterTestInfo(const char* pCaseName, const char* pTestName, testing::TestFactoryBase* pFactory) { return testing::UnitTest::self()->addTestInfo(pCaseName, pTestName, *pFactory); } std::string testing::GetBoolAssertionFailureMessage( const skypat::testing::AssertionResult& pAssertionResult, const char* pExpressionText, const char* pActualPredicateValue, const char* pExpectedPredicateValue) { std::string result; OStrStream OS(result); OS << "Value of: " << pExpressionText << "\n Actual: " << pActualPredicateValue; if (pAssertionResult.hasMessage()) OS << "(" << pAssertionResult.message() << ")"; OS << "\n Expected: " << pExpectedPredicateValue; return result; } //===----------------------------------------------------------------------===// // PerfIterator //===----------------------------------------------------------------------===// testing::PerfIterator::PerfIterator(const char* pFile, int pLine) : m_Counter(0), m_pTimer(new internal::Timer()), m_pPerf(new internal::Perf()), m_pPerfResult(testing::UnitTest::self()->addPerfPartResult(pFile, pLine)) { m_pTimer->start(); m_pPerf->start(); } testing::PerfIterator::PerfIterator(const char* pFile, int pLine,\ enum PerfEvent pEvent) : m_Counter(0), m_pTimer(new internal::Timer()), m_pPerf(new internal::Perf(pEvent)), m_pPerfResult(testing::UnitTest::self()->addPerfPartResult(pFile, pLine)) { m_pTimer->start(); m_pPerf->start(); } testing::PerfIterator::~PerfIterator() { delete m_pTimer; delete m_pPerf; } bool testing::PerfIterator::hasNext() const { if (m_Counter < SKYPAT_PERFORM_LOOP_TIMES) return true; m_pTimer->stop(); m_pPerf->stop(); m_pPerfResult->setTimerNum(m_pTimer->interval()); m_pPerfResult->setPerfEventNum(m_pPerf->interval()); m_pPerfResult->setPerfEventType(m_pPerf->eventType()); return false; } testing::PerfIterator& testing::PerfIterator::next() { ++m_Counter; return *this; } //===----------------------------------------------------------------------===// // PartResult //===----------------------------------------------------------------------===// testing::PartResult::PartResult(const std::string& pFileName, int pLoC) : m_FileName(pFileName), m_LoC(pLoC), m_Message() { } testing::PartResult::PartResult(const std::string& pFileName, int pLoC, const std::string& pMessage) : m_FileName(pFileName), m_LoC(pLoC), m_Message(pMessage) { } //===----------------------------------------------------------------------===// // TestPartResult //===----------------------------------------------------------------------===// testing::TestPartResult::TestPartResult(Type pType, const std::string& pFileName, int pLoC, const std::string& pMessage) : PartResult(pFileName, pLoC, pMessage), m_Type(pType) { } testing::TestPartResult& testing::TestPartResult::appendUserMessage(const std::string& pMessage) { if (!pMessage.empty()) update_message(message() + "\n" + pMessage); return *this; } //===----------------------------------------------------------------------===// // PerfPartResult //===----------------------------------------------------------------------===// testing::PerfPartResult::PerfPartResult(const std::string& pFileName, int pLoC) : PartResult(pFileName, pLoC) { } testing::Interval testing::PerfPartResult::getTimerNum() const { return m_PerfTimerNum; } testing::Interval testing::PerfPartResult::getPerfEventNum() const { return m_PerfEventNum; } testing::Interval testing::PerfPartResult::getPerfEventType() const { return m_PerfEventType; } void testing::PerfPartResult::setTimerNum(testing::Interval pTimerNum) { m_PerfTimerNum = pTimerNum; OStrStream os(m_Message); os << pTimerNum << " ns;"; } void testing::PerfPartResult::setPerfEventNum(testing::Interval pEventNum) { m_PerfEventNum = pEventNum; } void testing::PerfPartResult::setPerfEventType(testing::Interval pEventType) { m_PerfEventType = pEventType; } //===----------------------------------------------------------------------===// // TestResult //===----------------------------------------------------------------------===// testing::TestResult::TestResult(const TestInfo& pInfo) : m_Info(pInfo), m_Conclusion(kNotTested) { } testing::TestResult::~TestResult() { } bool testing::TestResult::isPassed() const { return (kPassed == m_Conclusion); } bool testing::TestResult::isFailed() const { return (kFailed == m_Conclusion); } const testing::TestResult::Reliability& testing::TestResult::reliability() const { return m_Info.getTestResults(); } const testing::TestResult::Performance& testing::TestResult::performance() const { return m_Info.getPerfResults(); } //===----------------------------------------------------------------------===// // TestCase //===----------------------------------------------------------------------===// testing::TestCase::TestCase(const std::string& pCaseName) : m_CaseName(pCaseName) { } testing::TestCase::~TestCase() { InfoList::iterator info, iEnd = m_InfoList.end(); for (info = m_InfoList.begin(); info != iEnd; ++info) { delete (*info); } } testing::TestInfo* testing::TestCase::addTestInfo(const std::string& pTestName, testing::TestFactoryBase& pFactory) { testing::TestInfo* info = new testing::TestInfo(this, pTestName, pFactory); m_InfoList.push_back(info); return info; } //===----------------------------------------------------------------------===// // TestInfo //===----------------------------------------------------------------------===// testing::TestInfo::TestInfo(TestCase* pTestCase, const std::string& pTestName, testing::TestFactoryBase& pFactory) : m_pTestCase(pTestCase), m_TestName(pTestName), m_Result(*this), m_pFactory(&pFactory) { } testing::TestInfo::~TestInfo() { delete m_pFactory; TestPartResultList::iterator tt, tEnd = m_TestResultList.end(); for (tt = m_TestResultList.begin(); tt != tEnd; ++tt) { delete (*tt); } PerfPartResultList::iterator pt, pEnd = m_PerfResultList.end(); for (pt = m_PerfResultList.begin(); pt != pEnd; ++pt) { delete (*pt); } } void testing::TestInfo::run() { UnitTest& unittest = *UnitTest::self(); Repeater& repeater = unittest.repeater(); skypat::Test* test = m_pFactory->CreateTest(); if (NULL != test) { repeater.OnSetUpStart(unittest); test->SetUp(); repeater.OnSetUpEnd(unittest); repeater.OnTestStart(*this); test->run(); repeater.OnTestEnd(*this); repeater.OnTearDownStart(unittest); test->TearDown(); repeater.OnTearDownEnd(unittest); } delete test; } void testing::TestInfo::addTestPartResult(const TestPartResult& pResult) { if (m_TestResultList.empty()) { m_Result.setConclusion(testing::TestResult::kPassed); } if (testing::TestPartResult::kSuccess != pResult.type()) { m_Result.setConclusion(testing::TestResult::kFailed); m_TestResultList.push_back(new TestPartResult(pResult)); } } testing::PerfPartResult* testing::TestInfo::addPerfPartResult(const char* pFile, int pLine) { PerfPartResult* perf_pr = new PerfPartResult(pFile, pLine); m_PerfResultList.push_back(perf_pr); return perf_pr; } //===----------------------------------------------------------------------===// // AssertionResult //===----------------------------------------------------------------------===// skypat::testing::AssertionResult::AssertionResult(const AssertionResult& pOther) : m_bSuccess(pOther.m_bSuccess), m_Message(pOther.m_Message) { } skypat::testing::AssertionResult::AssertionResult(bool pSuccess) : m_bSuccess(pSuccess) { } skypat::testing::AssertionResult skypat::testing::AssertionResult::operator!() const { AssertionResult negative(!m_bSuccess); negative << m_Message; return negative; } template skypat::testing::AssertionResult& skypat::testing::AssertionResult::operator<<(const T& pValue) { skypat::OStrStream OS(m_Message); OS << pValue; return *this; } skypat::testing::AssertionResult& skypat::testing::AssertionResult::operator<<( ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) { skypat::OStrStream OS(m_Message); OS << basic_manipulator; return *this; } //===----------------------------------------------------------------------===// // Message //===----------------------------------------------------------------------===// skypat::testing::Message::Message() : m_Message(), m_OSS(m_Message) { } //===----------------------------------------------------------------------===// // AssertHelper //===----------------------------------------------------------------------===// skypat::testing::AssertHelper::AssertHelper(TestPartResult::Type pType, const std::string& pFile, int pLineOfCode, const std::string& pMessage) : m_Result(pType, pFile, pLineOfCode, pMessage) { // m_Result is a TestPartResult } // Store a run-time result void skypat::testing::AssertHelper::operator=(const Message& pMesg) { m_Result.appendUserMessage(pMesg.str()); UnitTest::self()->addTestPartResult(m_Result); } //===----------------------------------------------------------------------===// // Log //===----------------------------------------------------------------------===// testing::Log::Log(Severity pSeverity, const std::string& pFileName, int pLoC) : m_Severity(pSeverity) { const char* const mesg = kInfo == pSeverity ? "[ INFO ]" : kWarning == pSeverity ? "[WARNING]" : kError == pSeverity ? "[ ERROR ]" : "[ FATAL ]"; getOStream() << std::endl << mesg << FormatFileLocation(pFileName, pLoC) << ": "; } testing::Log::~Log() { getOStream() << std::endl; if (kFatal == m_Severity) { shutdown(); fflush(stderr); exit(1); } } ::std::ostream& testing::Log::getOStream() { return ::std::cerr; } std::string testing::Log::FormatFileLocation(const std::string& pFileName, int pLoC) { std::string result; OStrStream OS(result); if (pFileName.empty()) OS << "(unknown file)"; else OS << pFileName; if (pLoC < 0) { OS << ":"; return result; } #ifdef _MSC_VER OS << "(" << pLoC << "):"; #else OS << ":" << pLoC << ":"; #endif // _MSC_VER return result; } SkyPat-3.2.0/lib/skypat.pc.in000066400000000000000000000003421465531052300157440ustar00rootroot00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: skypat Description: Performance Analysis Toolkit Requires: Version: @PACKAGE_VERSION@ Libs: -L${libdir} -lskypat Cflags: -I${includedir} SkyPat-3.2.0/m4/000077500000000000000000000000001465531052300132535ustar00rootroot00000000000000SkyPat-3.2.0/m4/acx_pthread.m4000066400000000000000000000317661465531052300160140ustar00rootroot00000000000000# This was retrieved from # http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?revision=1277&root=avahi # See also (perhaps for new versions?) # http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?root=avahi # # We've rewritten the inconsistency check code (from avahi), to work # more broadly. In particular, it no longer assumes ld accepts -zdefs. # This caused a restructing of the code, but the functionality has only # changed a little. dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) dnl dnl @summary figure out how to build C programs using POSIX threads dnl dnl This macro figures out how to build C programs using POSIX threads. dnl It sets the PTHREAD_LIBS output variable to the threads library and dnl linker flags, and the PTHREAD_CFLAGS output variable to any special dnl C compiler flags that are needed. (The user can also force certain dnl compiler flags/libs to be tested by setting these environment dnl variables.) dnl dnl Also sets PTHREAD_CC to any special C compiler that is needed for dnl multi-threaded programs (defaults to the value of CC otherwise). dnl (This is necessary on AIX to use the special cc_r compiler alias.) dnl dnl NOTE: You are assumed to not only compile your program with these dnl flags, but also link it with them as well. e.g. you should link dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS dnl $LIBS dnl dnl If you are only building threads programs, you may wish to use dnl these variables in your default LIBS, CFLAGS, and CC: dnl dnl LIBS="$PTHREAD_LIBS $LIBS" dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS" dnl CC="$PTHREAD_CC" dnl dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). dnl dnl ACTION-IF-FOUND is a list of shell commands to run if a threads dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the dnl default action will define HAVE_PTHREAD. dnl dnl Please let the authors know if this macro fails on any platform, or dnl if you have any other suggestions or comments. This macro was based dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros dnl posted by Alejandro Forero Cuervo to the autoconf macro repository. dnl We are also grateful for the helpful feedback of numerous users. dnl dnl @category InstalledPackages dnl @author Steven G. Johnson dnl @version 2006-05-29 dnl @license GPLWithACException dnl dnl Checks for GCC shared/pthread inconsistency based on work by dnl Marcin Owsiany AC_DEFUN([ACX_PTHREAD], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_LANG_SAVE AC_LANG_C acx_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) AC_MSG_RESULT($acx_pthread_ok) if test x"$acx_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthreads: Solaris/gcc # -mthreads: Mingw32/gcc, Lynx/gcc # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # ... -mt is also the pthreads flag for HP/aCC # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case "${host_cpu}-${host_os}" in *solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthreads/-mt/ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags" ;; esac if test x"$acx_pthread_ok" = xno; then for flag in $acx_pthread_flags; do case $flag in none) AC_MSG_CHECKING([whether pthreads work without any flags]) ;; -*) AC_MSG_CHECKING([whether pthreads work with $flag]) PTHREAD_CFLAGS="$flag" ;; pthread-config) AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) if test x"$acx_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) AC_MSG_CHECKING([for the pthreads library -l$flag]) PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. AC_TRY_LINK([#include ], [pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], [acx_pthread_ok=yes]) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" AC_MSG_RESULT($acx_pthread_ok) if test "x$acx_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$acx_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. AC_MSG_CHECKING([for joinable pthread attribute]) attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do AC_TRY_LINK([#include ], [int attr=$attr; return attr;], [attr_name=$attr; break]) done AC_MSG_RESULT($attr_name) if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, [Define to necessary symbol if this constant uses a non-standard name on your system.]) fi AC_MSG_CHECKING([if more special flags are required for pthreads]) flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; esac AC_MSG_RESULT(${flag}) if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: must compile with xlc_r or cc_r if test x"$GCC" != xyes; then AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) else PTHREAD_CC=$CC fi # The next part tries to detect GCC inconsistency with -shared on some # architectures and systems. The problem is that in certain # configurations, when -shared is specified, GCC "forgets" to # internally use various flags which are still necessary. # # Prepare the flags # save_CFLAGS="$CFLAGS" save_LIBS="$LIBS" save_CC="$CC" # Try with the flags determined by the earlier checks. # # -Wl,-z,defs forces link-time symbol resolution, so that the # linking checks with -shared actually have any value # # FIXME: -fPIC is required for -shared on many architectures, # so we specify it here, but the right way would probably be to # properly detect whether it is actually required. CFLAGS="-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CC="$PTHREAD_CC" # In order not to create several levels of indentation, we test # the value of "$done" until we find the cure or run out of ideas. done="no" # First, make sure the CFLAGS we added are actually accepted by our # compiler. If not (and OS X's ld, for instance, does not accept -z), # then we can't do this test. if test x"$done" = xno; then AC_MSG_CHECKING([whether to check for GCC pthread/shared inconsistencies]) AC_TRY_LINK(,, , [done=yes]) if test "x$done" = xyes ; then AC_MSG_RESULT([no]) else AC_MSG_RESULT([yes]) fi fi if test x"$done" = xno; then AC_MSG_CHECKING([whether -pthread is sufficient with -shared]) AC_TRY_LINK([#include ], [pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], [done=yes]) if test "x$done" = xyes; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi fi # # Linux gcc on some architectures such as mips/mipsel forgets # about -lpthread # if test x"$done" = xno; then AC_MSG_CHECKING([whether -lpthread fixes that]) LIBS="-lpthread $PTHREAD_LIBS $save_LIBS" AC_TRY_LINK([#include ], [pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], [done=yes]) if test "x$done" = xyes; then AC_MSG_RESULT([yes]) PTHREAD_LIBS="-lpthread $PTHREAD_LIBS" else AC_MSG_RESULT([no]) fi fi # # FreeBSD 4.10 gcc forgets to use -lc_r instead of -lc # if test x"$done" = xno; then AC_MSG_CHECKING([whether -lc_r fixes that]) LIBS="-lc_r $PTHREAD_LIBS $save_LIBS" AC_TRY_LINK([#include ], [pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], [done=yes]) if test "x$done" = xyes; then AC_MSG_RESULT([yes]) PTHREAD_LIBS="-lc_r $PTHREAD_LIBS" else AC_MSG_RESULT([no]) fi fi if test x"$done" = xno; then # OK, we have run out of ideas AC_MSG_WARN([Impossible to determine how to use pthreads with shared libraries]) # so it's not safe to assume that we may use pthreads acx_pthread_ok=no fi CFLAGS="$save_CFLAGS" LIBS="$save_LIBS" CC="$save_CC" else PTHREAD_CC="$CC" fi AC_SUBST(PTHREAD_LIBS) AC_SUBST(PTHREAD_CFLAGS) AC_SUBST(PTHREAD_CC) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$acx_pthread_ok" = xyes; then ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) : else acx_pthread_ok=no $2 fi AC_LANG_RESTORE ])dnl ACX_PTHREAD SkyPat-3.2.0/m4/ax_prog_doxygen.m4000066400000000000000000000427251465531052300167230ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_prog_doxygen.html # =========================================================================== # # SYNOPSIS # # DX_INIT_DOXYGEN(PROJECT-NAME, DOXYFILE-PATH, [OUTPUT-DIR]) # DX_DOXYGEN_FEATURE(ON|OFF) # DX_DOT_FEATURE(ON|OFF) # DX_HTML_FEATURE(ON|OFF) # DX_CHM_FEATURE(ON|OFF) # DX_CHI_FEATURE(ON|OFF) # DX_MAN_FEATURE(ON|OFF) # DX_RTF_FEATURE(ON|OFF) # DX_XML_FEATURE(ON|OFF) # DX_PDF_FEATURE(ON|OFF) # DX_PS_FEATURE(ON|OFF) # # DESCRIPTION # # The DX_*_FEATURE macros control the default setting for the given # Doxygen feature. Supported features are 'DOXYGEN' itself, 'DOT' for # generating graphics, 'HTML' for plain HTML, 'CHM' for compressed HTML # help (for MS users), 'CHI' for generating a seperate .chi file by the # .chm file, and 'MAN', 'RTF', 'XML', 'PDF' and 'PS' for the appropriate # output formats. The environment variable DOXYGEN_PAPER_SIZE may be # specified to override the default 'a4wide' paper size. # # By default, HTML, PDF and PS documentation is generated as this seems to # be the most popular and portable combination. MAN pages created by # Doxygen are usually problematic, though by picking an appropriate subset # and doing some massaging they might be better than nothing. CHM and RTF # are specific for MS (note that you can't generate both HTML and CHM at # the same time). The XML is rather useless unless you apply specialized # post-processing to it. # # The macros mainly control the default state of the feature. The use can # override the default by specifying --enable or --disable. The macros # ensure that contradictory flags are not given (e.g., # --enable-doxygen-html and --enable-doxygen-chm, # --enable-doxygen-anything with --disable-doxygen, etc.) Finally, each # feature will be automatically disabled (with a warning) if the required # programs are missing. # # Once all the feature defaults have been specified, call DX_INIT_DOXYGEN # with the following parameters: a one-word name for the project for use # as a filename base etc., an optional configuration file name (the # default is 'Doxyfile', the same as Doxygen's default), and an optional # output directory name (the default is 'doxygen-doc'). # # Automake Support # # The following is a template aminclude.am file for use with Automake. # Make targets and variables values are controlled by the various # DX_COND_* conditionals set by autoconf. # # The provided targets are: # # doxygen-doc: Generate all doxygen documentation. # # doxygen-run: Run doxygen, which will generate some of the # documentation (HTML, CHM, CHI, MAN, RTF, XML) # but will not do the post processing required # for the rest of it (PS, PDF, and some MAN). # # doxygen-man: Rename some doxygen generated man pages. # # doxygen-ps: Generate doxygen PostScript documentation. # # doxygen-pdf: Generate doxygen PDF documentation. # # Note that by default these are not integrated into the automake targets. # If doxygen is used to generate man pages, you can achieve this # integration by setting man3_MANS to the list of man pages generated and # then adding the dependency: # # $(man3_MANS): doxygen-doc # # This will cause make to run doxygen and generate all the documentation. # # The following variable is intended for use in Makefile.am: # # DX_CLEANFILES = everything to clean. # # Then add this variable to MOSTLYCLEANFILES. # # ----- begin aminclude.am ------------------------------------- # # ## --------------------------------- ## # ## Format-independent Doxygen rules. ## # ## --------------------------------- ## # # if DX_COND_doc # # ## ------------------------------- ## # ## Rules specific for HTML output. ## # ## ------------------------------- ## # # if DX_COND_html # # DX_CLEAN_HTML = @DX_DOCDIR@/html # # endif DX_COND_html # # ## ------------------------------ ## # ## Rules specific for CHM output. ## # ## ------------------------------ ## # # if DX_COND_chm # # DX_CLEAN_CHM = @DX_DOCDIR@/chm # # if DX_COND_chi # # DX_CLEAN_CHI = @DX_DOCDIR@/@PACKAGE@.chi # # endif DX_COND_chi # # endif DX_COND_chm # # ## ------------------------------ ## # ## Rules specific for MAN output. ## # ## ------------------------------ ## # # if DX_COND_man # # DX_CLEAN_MAN = @DX_DOCDIR@/man # # endif DX_COND_man # # ## ------------------------------ ## # ## Rules specific for RTF output. ## # ## ------------------------------ ## # # if DX_COND_rtf # # DX_CLEAN_RTF = @DX_DOCDIR@/rtf # # endif DX_COND_rtf # # ## ------------------------------ ## # ## Rules specific for XML output. ## # ## ------------------------------ ## # # if DX_COND_xml # # DX_CLEAN_XML = @DX_DOCDIR@/xml # # endif DX_COND_xml # # ## ----------------------------- ## # ## Rules specific for PS output. ## # ## ----------------------------- ## # # if DX_COND_ps # # DX_CLEAN_PS = @DX_DOCDIR@/@PACKAGE@.ps # # DX_PS_GOAL = doxygen-ps # # doxygen-ps: @DX_DOCDIR@/@PACKAGE@.ps # # @DX_DOCDIR@/@PACKAGE@.ps: @DX_DOCDIR@/@PACKAGE@.tag # cd @DX_DOCDIR@/latex; \ # rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \ # $(DX_LATEX) refman.tex; \ # $(MAKEINDEX_PATH) refman.idx; \ # $(DX_LATEX) refman.tex; \ # countdown=5; \ # while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \ # refman.log > /dev/null 2>&1 \ # && test $$countdown -gt 0; do \ # $(DX_LATEX) refman.tex; \ # countdown=`expr $$countdown - 1`; \ # done; \ # $(DX_DVIPS) -o ../@PACKAGE@.ps refman.dvi # # endif DX_COND_ps # # ## ------------------------------ ## # ## Rules specific for PDF output. ## # ## ------------------------------ ## # # if DX_COND_pdf # # DX_CLEAN_PDF = @DX_DOCDIR@/@PACKAGE@.pdf # # DX_PDF_GOAL = doxygen-pdf # # doxygen-pdf: @DX_DOCDIR@/@PACKAGE@.pdf # # @DX_DOCDIR@/@PACKAGE@.pdf: @DX_DOCDIR@/@PACKAGE@.tag # cd @DX_DOCDIR@/latex; \ # rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \ # $(DX_PDFLATEX) refman.tex; \ # $(DX_MAKEINDEX) refman.idx; \ # $(DX_PDFLATEX) refman.tex; \ # countdown=5; \ # while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \ # refman.log > /dev/null 2>&1 \ # && test $$countdown -gt 0; do \ # $(DX_PDFLATEX) refman.tex; \ # countdown=`expr $$countdown - 1`; \ # done; \ # mv refman.pdf ../@PACKAGE@.pdf # # endif DX_COND_pdf # # ## ------------------------------------------------- ## # ## Rules specific for LaTeX (shared for PS and PDF). ## # ## ------------------------------------------------- ## # # if DX_COND_latex # # DX_CLEAN_LATEX = @DX_DOCDIR@/latex # # endif DX_COND_latex # # .PHONY: doxygen-run doxygen-doc $(DX_PS_GOAL) $(DX_PDF_GOAL) # # .INTERMEDIATE: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL) # # doxygen-run: @DX_DOCDIR@/@PACKAGE@.tag # # doxygen-doc: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL) # # @DX_DOCDIR@/@PACKAGE@.tag: $(DX_CONFIG) $(pkginclude_HEADERS) # rm -rf @DX_DOCDIR@ # $(DX_ENV) $(DX_DOXYGEN) $(srcdir)/$(DX_CONFIG) # # DX_CLEANFILES = \ # @DX_DOCDIR@/@PACKAGE@.tag \ # -r \ # $(DX_CLEAN_HTML) \ # $(DX_CLEAN_CHM) \ # $(DX_CLEAN_CHI) \ # $(DX_CLEAN_MAN) \ # $(DX_CLEAN_RTF) \ # $(DX_CLEAN_XML) \ # $(DX_CLEAN_PS) \ # $(DX_CLEAN_PDF) \ # $(DX_CLEAN_LATEX) # # endif DX_COND_doc # # ----- end aminclude.am --------------------------------------- # # LICENSE # # Copyright (c) 2009 Oren Ben-Kiki # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 12 ## ----------## ## Defaults. ## ## ----------## DX_ENV="" AC_DEFUN([DX_FEATURE_doc], ON) AC_DEFUN([DX_FEATURE_dot], OFF) AC_DEFUN([DX_FEATURE_man], OFF) AC_DEFUN([DX_FEATURE_html], ON) AC_DEFUN([DX_FEATURE_chm], OFF) AC_DEFUN([DX_FEATURE_chi], OFF) AC_DEFUN([DX_FEATURE_rtf], OFF) AC_DEFUN([DX_FEATURE_xml], OFF) AC_DEFUN([DX_FEATURE_pdf], ON) AC_DEFUN([DX_FEATURE_ps], ON) ## --------------- ## ## Private macros. ## ## --------------- ## # DX_ENV_APPEND(VARIABLE, VALUE) # ------------------------------ # Append VARIABLE="VALUE" to DX_ENV for invoking doxygen. AC_DEFUN([DX_ENV_APPEND], [AC_SUBST([DX_ENV], ["$DX_ENV $1='$2'"])]) # DX_DIRNAME_EXPR # --------------- # Expand into a shell expression prints the directory part of a path. AC_DEFUN([DX_DIRNAME_EXPR], [[expr ".$1" : '\(\.\)[^/]*$' \| "x$1" : 'x\(.*\)/[^/]*$']]) # DX_IF_FEATURE(FEATURE, IF-ON, IF-OFF) # ------------------------------------- # Expands according to the M4 (static) status of the feature. AC_DEFUN([DX_IF_FEATURE], [ifelse(DX_FEATURE_$1, ON, [$2], [$3])]) # DX_REQUIRE_PROG(VARIABLE, PROGRAM) # ---------------------------------- # Require the specified program to be found for the DX_CURRENT_FEATURE to work. AC_DEFUN([DX_REQUIRE_PROG], [ AC_PATH_TOOL([$1], [$2]) if test "$DX_FLAG_[]DX_CURRENT_FEATURE$$1" = 1; then AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION]) AC_SUBST(DX_FLAG_[]DX_CURRENT_FEATURE, 0) fi ]) # DX_TEST_FEATURE(FEATURE) # ------------------------ # Expand to a shell expression testing whether the feature is active. AC_DEFUN([DX_TEST_FEATURE], [test "$DX_FLAG_$1" = 1]) # DX_CHECK_DEPEND(REQUIRED_FEATURE, REQUIRED_STATE) # ------------------------------------------------- # Verify that a required features has the right state before trying to turn on # the DX_CURRENT_FEATURE. AC_DEFUN([DX_CHECK_DEPEND], [ test "$DX_FLAG_$1" = "$2" \ || AC_MSG_ERROR([doxygen-DX_CURRENT_FEATURE ifelse([$2], 1, requires, contradicts) doxygen-DX_CURRENT_FEATURE]) ]) # DX_CLEAR_DEPEND(FEATURE, REQUIRED_FEATURE, REQUIRED_STATE) # ---------------------------------------------------------- # Turn off the DX_CURRENT_FEATURE if the required feature is off. AC_DEFUN([DX_CLEAR_DEPEND], [ test "$DX_FLAG_$1" = "$2" || AC_SUBST(DX_FLAG_[]DX_CURRENT_FEATURE, 0) ]) # DX_FEATURE_ARG(FEATURE, DESCRIPTION, # CHECK_DEPEND, CLEAR_DEPEND, # REQUIRE, DO-IF-ON, DO-IF-OFF) # -------------------------------------------- # Parse the command-line option controlling a feature. CHECK_DEPEND is called # if the user explicitly turns the feature on (and invokes DX_CHECK_DEPEND), # otherwise CLEAR_DEPEND is called to turn off the default state if a required # feature is disabled (using DX_CLEAR_DEPEND). REQUIRE performs additional # requirement tests (DX_REQUIRE_PROG). Finally, an automake flag is set and # DO-IF-ON or DO-IF-OFF are called according to the final state of the feature. AC_DEFUN([DX_ARG_ABLE], [ AC_DEFUN([DX_CURRENT_FEATURE], [$1]) AC_DEFUN([DX_CURRENT_DESCRIPTION], [$2]) AC_ARG_ENABLE(doxygen-$1, [AS_HELP_STRING(DX_IF_FEATURE([$1], [--disable-doxygen-$1], [--enable-doxygen-$1]), DX_IF_FEATURE([$1], [don't $2], [$2]))], [ case "$enableval" in #( y|Y|yes|Yes|YES) AC_SUBST([DX_FLAG_$1], 1) $3 ;; #( n|N|no|No|NO) AC_SUBST([DX_FLAG_$1], 0) ;; #( *) AC_MSG_ERROR([invalid value '$enableval' given to doxygen-$1]) ;; esac ], [ AC_SUBST([DX_FLAG_$1], [DX_IF_FEATURE([$1], 1, 0)]) $4 ]) if DX_TEST_FEATURE([$1]); then $5 : fi AM_CONDITIONAL(DX_COND_$1, DX_TEST_FEATURE([$1])) if DX_TEST_FEATURE([$1]); then $6 : else $7 : fi ]) ## -------------- ## ## Public macros. ## ## -------------- ## # DX_XXX_FEATURE(DEFAULT_STATE) # ----------------------------- AC_DEFUN([DX_DOXYGEN_FEATURE], [AC_DEFUN([DX_FEATURE_doc], [$1])]) AC_DEFUN([DX_DOT_FEATURE], [AC_DEFUN([DX_FEATURE_dot], [$1])]) AC_DEFUN([DX_MAN_FEATURE], [AC_DEFUN([DX_FEATURE_man], [$1])]) AC_DEFUN([DX_HTML_FEATURE], [AC_DEFUN([DX_FEATURE_html], [$1])]) AC_DEFUN([DX_CHM_FEATURE], [AC_DEFUN([DX_FEATURE_chm], [$1])]) AC_DEFUN([DX_CHI_FEATURE], [AC_DEFUN([DX_FEATURE_chi], [$1])]) AC_DEFUN([DX_RTF_FEATURE], [AC_DEFUN([DX_FEATURE_rtf], [$1])]) AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])]) AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])]) AC_DEFUN([DX_PDF_FEATURE], [AC_DEFUN([DX_FEATURE_pdf], [$1])]) AC_DEFUN([DX_PS_FEATURE], [AC_DEFUN([DX_FEATURE_ps], [$1])]) # DX_INIT_DOXYGEN(PROJECT, [CONFIG-FILE], [OUTPUT-DOC-DIR]) # --------------------------------------------------------- # PROJECT also serves as the base name for the documentation files. # The default CONFIG-FILE is "Doxyfile" and OUTPUT-DOC-DIR is "doxygen-doc". AC_DEFUN([DX_INIT_DOXYGEN], [ # Files: AC_SUBST([DX_PROJECT], [$1]) AC_SUBST([DX_CONFIG], [ifelse([$2], [], Doxyfile, [$2])]) AC_SUBST([DX_DOCDIR], [ifelse([$3], [], doxygen-doc, [$3])]) # Environment variables used inside doxygen.cfg: DX_ENV_APPEND(SRCDIR, $srcdir) DX_ENV_APPEND(PROJECT, $DX_PROJECT) DX_ENV_APPEND(DOCDIR, $DX_DOCDIR) DX_ENV_APPEND(VERSION, $PACKAGE_VERSION) # Doxygen itself: DX_ARG_ABLE(doc, [generate any doxygen documentation], [], [], [DX_REQUIRE_PROG([DX_DOXYGEN], doxygen) DX_REQUIRE_PROG([DX_PERL], perl)], [DX_ENV_APPEND(PERL_PATH, $DX_PERL)]) # Dot for graphics: DX_ARG_ABLE(dot, [generate graphics for doxygen documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [DX_REQUIRE_PROG([DX_DOT], dot)], [DX_ENV_APPEND(HAVE_DOT, YES) DX_ENV_APPEND(DOT_PATH, [`DX_DIRNAME_EXPR($DX_DOT)`])], [DX_ENV_APPEND(HAVE_DOT, NO)]) # Man pages generation: DX_ARG_ABLE(man, [generate doxygen manual pages], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [], [DX_ENV_APPEND(GENERATE_MAN, YES)], [DX_ENV_APPEND(GENERATE_MAN, NO)]) # RTF file generation: DX_ARG_ABLE(rtf, [generate doxygen RTF documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [], [DX_ENV_APPEND(GENERATE_RTF, YES)], [DX_ENV_APPEND(GENERATE_RTF, NO)]) # XML file generation: DX_ARG_ABLE(xml, [generate doxygen XML documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [], [DX_ENV_APPEND(GENERATE_XML, YES)], [DX_ENV_APPEND(GENERATE_XML, NO)]) # (Compressed) HTML help generation: DX_ARG_ABLE(chm, [generate doxygen compressed HTML help documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [DX_REQUIRE_PROG([DX_HHC], hhc)], [DX_ENV_APPEND(HHC_PATH, $DX_HHC) DX_ENV_APPEND(GENERATE_HTML, YES) DX_ENV_APPEND(GENERATE_HTMLHELP, YES)], [DX_ENV_APPEND(GENERATE_HTMLHELP, NO)]) # Seperate CHI file generation. DX_ARG_ABLE(chi, [generate doxygen seperate compressed HTML help index file], [DX_CHECK_DEPEND(chm, 1)], [DX_CLEAR_DEPEND(chm, 1)], [], [DX_ENV_APPEND(GENERATE_CHI, YES)], [DX_ENV_APPEND(GENERATE_CHI, NO)]) # Plain HTML pages generation: DX_ARG_ABLE(html, [generate doxygen plain HTML documentation], [DX_CHECK_DEPEND(doc, 1) DX_CHECK_DEPEND(chm, 0)], [DX_CLEAR_DEPEND(doc, 1) DX_CLEAR_DEPEND(chm, 0)], [], [DX_ENV_APPEND(GENERATE_HTML, YES)], [DX_TEST_FEATURE(chm) || DX_ENV_APPEND(GENERATE_HTML, NO)]) # PostScript file generation: DX_ARG_ABLE(ps, [generate doxygen PostScript documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [DX_REQUIRE_PROG([DX_LATEX], latex) DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex) DX_REQUIRE_PROG([DX_DVIPS], dvips) DX_REQUIRE_PROG([DX_EGREP], egrep)]) # PDF file generation: DX_ARG_ABLE(pdf, [generate doxygen PDF documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [DX_REQUIRE_PROG([DX_PDFLATEX], pdflatex) DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex) DX_REQUIRE_PROG([DX_EGREP], egrep)]) # LaTeX generation for PS and/or PDF: AM_CONDITIONAL(DX_COND_latex, DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf)) if DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf); then DX_ENV_APPEND(GENERATE_LATEX, YES) else DX_ENV_APPEND(GENERATE_LATEX, NO) fi # Paper size for PS and/or PDF: AC_ARG_VAR(DOXYGEN_PAPER_SIZE, [a4wide (default), a4, letter, legal or executive]) case "$DOXYGEN_PAPER_SIZE" in #( "") AC_SUBST(DOXYGEN_PAPER_SIZE, "") ;; #( a4wide|a4|letter|legal|executive) DX_ENV_APPEND(PAPER_SIZE, $DOXYGEN_PAPER_SIZE) ;; #( *) AC_MSG_ERROR([unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE']) ;; esac #For debugging: #echo DX_FLAG_doc=$DX_FLAG_doc #echo DX_FLAG_dot=$DX_FLAG_dot #echo DX_FLAG_man=$DX_FLAG_man #echo DX_FLAG_html=$DX_FLAG_html #echo DX_FLAG_chm=$DX_FLAG_chm #echo DX_FLAG_chi=$DX_FLAG_chi #echo DX_FLAG_rtf=$DX_FLAG_rtf #echo DX_FLAG_xml=$DX_FLAG_xml #echo DX_FLAG_pdf=$DX_FLAG_pdf #echo DX_FLAG_ps=$DX_FLAG_ps #echo DX_ENV=$DX_ENV ]) SkyPat-3.2.0/m4/canoncial_system.m4000066400000000000000000000135271465531052300170600ustar00rootroot00000000000000dnl dnl @synopsis CHECK_CANONICAL_SYSTEM dnl dnl @summary set up default value of `host`, `build` and `target` dnl dnl Luba Tang AC_DEFUN([CHECK_CANONICAL_SYSTEM], [dnl AC_CANONICAL_HOST AC_CACHE_CHECK([type of operating system we're going to host on], [skypat_cv_host_os_type], [case $host in *-*-aix*) skypat_cv_host_os_type="AIX" skypat_cv_host_platform_type="Unix" ;; *-*-irix*) skypat_cv_host_os_type="IRIX" skypat_cv_host_platform_type="Unix" ;; *-*-cygwin*) skypat_cv_host_os_type="Cygwin" skypat_cv_host_platform_type="Unix" ;; *-*-darwin*) skypat_cv_host_os_type="Darwin" skypat_cv_host_platform_type="Unix" ;; *-*-minix*) skypat_cv_host_os_type="Minix" skypat_cv_host_platform_type="Unix" ;; *-*-freebsd*) skypat_cv_host_os_type="FreeBSD" skypat_cv_host_platform_type="Unix" ;; *-*-openbsd*) skypat_cv_host_os_type="OpenBSD" skypat_cv_host_platform_type="Unix" ;; *-*-netbsd*) skypat_cv_host_os_type="NetBSD" skypat_cv_host_platform_type="Unix" ;; *-*-dragonfly*) skypat_cv_host_os_type="DragonFly" skypat_cv_host_platform_type="Unix" ;; *-*-hpux*) skypat_cv_host_os_type="HP-UX" skypat_cv_host_platform_type="Unix" ;; *-*-interix*) skypat_cv_host_os_type="Interix" skypat_cv_host_platform_type="Unix" ;; *-*-linux*) skypat_cv_host_os_type="Linux" skypat_cv_host_platform_type="Unix" ;; *-*-solaris*) skypat_cv_host_os_type="SunOS" skypat_cv_host_platform_type="Unix" ;; *-*-auroraux*) skypat_cv_host_os_type="AuroraUX" skypat_cv_host_platform_type="Unix" ;; *-*-win32*) skypat_cv_host_os_type="Win32" skypat_cv_host_platform_type="Win32" ;; *-*-mingw*) skypat_cv_host_os_type="MingW" skypat_cv_host_platform_type="Win32" ;; *-*-haiku*) skypat_cv_host_os_type="Haiku" skypat_cv_host_platform_type="Unix" ;; *-unknown-eabi*) skypat_cv_host_os_type="Freestanding" skypat_cv_host_platform_type="Unix" ;; *-unknown-elf*) skypat_cv_host_os_type="Freestanding" skypat_cv_host_platform_type="Unix" ;; *) skypat_cv_host_os_type="Unknown" skypat_cv_host_platform_type="Unknown" ;; esac]) dnl Set the "OS" Makefile variable based on the platform type so the dnl makefile can configure itself to specific build hosts if test "$skypat_cv_host_os_type" = "Unknown" ; then AC_MSG_ERROR([Operating system is unknown, configure can't continue]) fi dnl Set the "SKYPAT_ON_*" variables based on llvm_cv_llvm_cv_platform_type dnl This is used by lib/Support to determine the basic kind of implementation dnl to use. case $skypat_cv_host_platform_type in Unix) AC_DEFINE([SKYPAT_ON_UNIX],[1],[Define if this is Unixish platform]) AC_SUBST(SKYPAT_ON_PLATFORM,[SKYPAT_ON_UNIX]) ;; Win32) AC_DEFINE([SKYPAT_ON_WIN32],[1],[Define if this is Win32ish platform]) AC_SUBST(SKYPAT_ON_PLATFORM,[SKYPAT_ON_WIN32]) ;; esac AC_SUBST(HOST_OS,$skypat_cv_host_os_type) AC_CANONICAL_TARGET AC_CACHE_CHECK([type of operating system we're going to target], [skypat_cv_target_os_type], [case $target in *-*-aix*) skypat_cv_target_os_type="AIX" ;; *-*-irix*) skypat_cv_target_os_type="IRIX" ;; *-*-cygwin*) skypat_cv_target_os_type="Cygwin" ;; *-*-darwin*) skypat_cv_target_os_type="Darwin" ;; *-*-minix*) skypat_cv_target_os_type="Minix" ;; *-*-freebsd* | *-*-kfreebsd-gnu) skypat_cv_target_os_type="FreeBSD" ;; *-*-openbsd*) skypat_cv_target_os_type="OpenBSD" ;; *-*-netbsd*) skypat_cv_target_os_type="NetBSD" ;; *-*-dragonfly*) skypat_cv_target_os_type="DragonFly" ;; *-*-hpux*) skypat_cv_target_os_type="HP-UX" ;; *-*-interix*) skypat_cv_target_os_type="Interix" ;; *-*-linux*) skypat_cv_target_os_type="Linux" ;; *-*-gnu*) skypat_cv_target_os_type="GNU" ;; *-*-solaris*) skypat_cv_target_os_type="SunOS" ;; *-*-auroraux*) skypat_cv_target_os_type="AuroraUX" ;; *-*-win32*) skypat_cv_target_os_type="Win32" ;; *-*-mingw*) skypat_cv_target_os_type="MingW" ;; *-*-haiku*) skypat_cv_target_os_type="Haiku" ;; *-*-rtems*) skypat_cv_target_os_type="RTEMS" ;; *-*-nacl*) skypat_cv_target_os_type="NativeClient" ;; *-unknown-eabi*) skypat_cv_target_os_type="Freestanding" ;; *) skypat_cv_target_os_type="Unknown" ;; esac]) if test "$skypat_cv_target_os_type" = "Unknown" ; then AC_MSG_WARN([Configuring for an unknown target operating system]) fi AC_SUBST(TARGET_OS,$skypat_cv_target_os_type) AC_CACHE_CHECK([target architecture], [skypat_cv_target_arch_type], [case $target in i?86-*) skypat_cv_target_arch_type="x86" ;; amd64-* | x86_64-*) skypat_cv_target_arch_type="x86_64" ;; sparc*-*) skypat_cv_target_arch_type="Sparc" ;; powerpc*-*) skypat_cv_target_arch_type="PowerPC" ;; arm*-*) skypat_cv_target_arch_type="ARM" ;; aarch64*-*) skypat_cv_target_arch_type="AArch64" ;; mips-* | mips64-*) skypat_cv_target_arch_type="Mips" ;; mipsel-* | mips64el-*) skypat_cv_target_arch_type="Mips" ;; xcore-*) skypat_cv_target_arch_type="XCore" ;; msp430-*) skypat_cv_target_arch_type="MSP430" ;; hexagon-*) skypat_cv_target_arch_type="Hexagon" ;; mblaze-*) skypat_cv_target_arch_type="MBlaze" ;; nvptx-*) skypat_cv_target_arch_type="NVPTX" ;; *) skypat_cv_target_arch_type="Unknown" ;; esac]) if test "$skypat_cv_target_arch_type" = "Unknown" ; then AC_MSG_WARN([Configuring for an unknown target architecture]) fi AC_SUBST(TARGET_ARCH,$skypat_cv_target_arch_type) dnl Set the "SKYPAT_DEFAULT_TARGET_TRIPLE" variable based on $target. dnl This is used to determine the default target triple and emulation dnl to use. AC_DEFINE([SKYPAT_DEFAULT_TARGET_TRIPLE], [$target], [default target triple]) ]) SkyPat-3.2.0/m4/config.m4000066400000000000000000000010551465531052300147630ustar00rootroot00000000000000dnl dnl @synopsis SETUP_CONFIG_HEADER dnl dnl @summary set up Config/Config.h dnl dnl Luba Tang AC_DEFUN([SETUP_CONFIG_HEADER], [dnl AH_TOP([ //===- Config.h.in --------------------------------------------------------===// // // The SkyPat Team // This file is distributed under the New BSD License. // See LICENSE for details. // //===----------------------------------------------------------------------===// #ifndef SKYPAT_CONFIG_CONFIG_H #define SKYPAT_CONFIG_CONFIG_H ]) AH_BOTTOM([ #endif ]) ]) SkyPat-3.2.0/m4/cxx_flag_check.m4000066400000000000000000000007251465531052300164510ustar00rootroot00000000000000dnl dnl @synopsis CXX_FLAGS_CHECK [compiler flags] dnl dnl @summary check whether compiler supports given C++ flags or not dnl dnl Luba Tang AC_DEFUN([CXX_FLAG_CHECK], [dnl AC_MSG_CHECKING([if $CXX supports $1]) AC_LANG_PUSH([C++]) ac_saved_cxxflags="$CXXFLAGS" CXXFLAGS="-Werror $1" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([no])] ) CXXFLAGS="$ac_saved_cxxflags" AC_LANG_POP([C++]) ]) SkyPat-3.2.0/m4/enable_option.m4000066400000000000000000000006011465531052300163300ustar00rootroot00000000000000AC_DEFUN([CHECK_ENABLE_OPTION], [dnl dnl $1: option name dnl $2: default value ("yes" or "no") dnl $3: define $3 if yes AC_ARG_ENABLE($1, [AS_HELP_STRING([--enable-$1], [turn on $1 (default is $2)])], [], [enable_$1=$2]) AM_CONDITIONAL([$3],[test "x${enable_$1}" == "xyes" ]) AS_IF([test "x${enable_$1}" = "xyes"], [AC_DEFINE($3, 1, [Enable $1])] ) ]) SkyPat-3.2.0/m4/optimize.m4000066400000000000000000000010621465531052300153540ustar00rootroot00000000000000dnl dnl @synopsis CHECK_ENABLE_OPTIMIZE dnl dnl @summary check --enable-optimize dnl dnl Luba Tang AC_DEFUN([CHECK_ENABLE_OPTIMIZE], [dnl AC_ARG_ENABLE(optimize, [AS_HELP_STRING([--enable-optimize], [turn on unit-tests (default is no)])], [case "${enableval}" in yes) optimize=true ;; no) optimize=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-optimize) ;; esac], [optimize=false]) AM_CONDITIONAL([ENABLE_OPTIMIZE],[test "x${optimize}" = "xtrue" ]) ]) SkyPat-3.2.0/m4/pthread_check.m4000066400000000000000000000013231465531052300163000ustar00rootroot00000000000000dnl dnl @synopsis CHECK_PTHREAD dnl dnl @summary check pthread library dnl dnl Luba Tang AC_DEFUN([CHECK_PTHREAD], [dnl # Configure pthreads. AC_ARG_WITH([pthreads], [AS_HELP_STRING([--with-pthreads], [use pthreads (default is yes)])], [with_pthreads=$withval], [with_pthreads=check]) have_pthreads=no AS_IF([test "x$with_pthreads" != "xno"], [ACX_PTHREAD( [], [AS_IF([test "x$with_pthreads" != "xcheck"], [AC_MSG_FAILURE( [--with-pthreads was specified, but unable to be used])])]) have_pthreads="$acx_pthread_ok"]) AM_CONDITIONAL([HAVE_PTHREADS],[test "x$have_pthreads" == "xyes"]) ]) SkyPat-3.2.0/m4/stl_hash.m4000066400000000000000000000065061465531052300153310ustar00rootroot00000000000000# We check two things: where the include file is for # unordered_map/hash_map (we prefer the first form), and what # namespace unordered/hash_map lives in within that include file. We # include AC_TRY_COMPILE for all the combinations we've seen in the # wild. We define HASH_MAP_H to the location of the header file, and # HASH_NAMESPACE to the namespace the class (unordered_map or # hash_map) is in. We define HAVE_UNORDERED_MAP if the class we found # is named unordered_map, or leave it undefined if not. # This also checks if unordered map exists. AC_DEFUN([AC_CXX_STL_HASH], [ AC_MSG_CHECKING(the location of hash_map) AC_LANG_SAVE AC_LANG_CPLUSPLUS ac_cv_cxx_hash_map="" # First try unordered_map, but not on gcc's before 4.2 -- I've # seen unexplainable unordered_map bugs with -O2 on older gcc's. AC_TRY_COMPILE([#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)) # error GCC too old for unordered_map #endif ], [/* no program body necessary */], [stl_hash_old_gcc=no], [stl_hash_old_gcc=yes]) for location in unordered_map tr1/unordered_map; do for namespace in std std::tr1; do if test -z "$ac_cv_cxx_hash_map" -a "$stl_hash_old_gcc" != yes; then # Some older gcc's have a buggy tr1, so test a bit of code. AC_TRY_COMPILE([#include <$location>], [const ${namespace}::unordered_map t; return t.find(5) == t.end();], [ac_cv_cxx_hash_map="<$location>"; ac_cv_cxx_hash_namespace="$namespace"; ac_cv_cxx_hash_map_class="unordered_map";]) fi done done # Now try hash_map for location in ext/hash_map hash_map; do for namespace in __gnu_cxx "" std stdext; do if test -z "$ac_cv_cxx_hash_map"; then AC_TRY_COMPILE([#include <$location>], [${namespace}::hash_map t], [ac_cv_cxx_hash_map="<$location>"; ac_cv_cxx_hash_namespace="$namespace"; ac_cv_cxx_hash_map_class="hash_map";]) fi done done ac_cv_cxx_hash_set=`echo "$ac_cv_cxx_hash_map" | sed s/map/set/`; ac_cv_cxx_hash_set_class=`echo "$ac_cv_cxx_hash_map_class" | sed s/map/set/`; if test -n "$ac_cv_cxx_hash_map"; then AC_DEFINE(HAVE_HASH_MAP, 1, [define if the compiler has hash_map]) AC_DEFINE(HAVE_HASH_SET, 1, [define if the compiler has hash_set]) AC_DEFINE_UNQUOTED(HASH_MAP_H,$ac_cv_cxx_hash_map, [the location of or ]) AC_DEFINE_UNQUOTED(HASH_SET_H,$ac_cv_cxx_hash_set, [the location of or ]) AC_DEFINE_UNQUOTED(HASH_NAMESPACE,$ac_cv_cxx_hash_namespace, [the namespace of hash_map/hash_set]) AC_DEFINE_UNQUOTED(HASH_MAP_CLASS,$ac_cv_cxx_hash_map_class, [the name of ]) AC_DEFINE_UNQUOTED(HASH_SET_CLASS,$ac_cv_cxx_hash_set_class, [the name of ]) AC_MSG_RESULT([$ac_cv_cxx_hash_map]) else AC_MSG_RESULT() AC_MSG_WARN([could not find an STL hash_map]) fi ]) SkyPat-3.2.0/m4/unittest.m4000066400000000000000000000010521465531052300153720ustar00rootroot00000000000000dnl dnl @synopsis CHECK_ENABLE_UNITTEST dnl dnl @summary enable unittest dnl dnl Luba Tang AC_DEFUN([CHECK_ENABLE_UNITTEST], [dnl AC_ARG_ENABLE(unittest, [AS_HELP_STRING([--enable-unittest], [turn on unit-tests (default is no)])], [case "${enableval}" in yes) unittest=true ;; no) unittest=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-unittest) ;; esac], [unittest=false]) AM_CONDITIONAL([ENABLE_UNITTEST],[test "x${unittest}" = "xtrue" ]) ]) SkyPat-3.2.0/m4/werror-flags.m4000066400000000000000000000011471465531052300161320ustar00rootroot00000000000000dnl dnl @synopsis CHECK_WERROR_FLAGS dnl dnl @summary check compiler's warning flags. dnl dnl Luba Tang dnl From Kito Cheng AC_DEFUN([CHECK_WERROR_FLAGS], [dnl AC_ARG_ENABLE(werror, AS_HELP_STRING([--enable-werror], [Compile with -Werror enabled (default is NO)]), [case "${enableval}" in yes) enable_werror=true ;; no) enable_werror=false ;; *) AC_MSG_ERROR([Invalid setting for --enable-werror. Use "yes" or "no"]) ;; esac], [enable_werror="no"]) AM_CONDITIONAL([ENABLE_WERROR], [test x${enable_werror} = xtrue]) ]) SkyPat-3.2.0/m4/zlib_check.m4000066400000000000000000000026701465531052300156170ustar00rootroot00000000000000dnl dnl @synopsis CHECK_ZLIB dnl dnl @summary check zlib library dnl dnl TDYa127 dnl Base on protobuf's configure.ac. AC_DEFUN([CHECK_ZLIB], [dnl # Configure zlibs. AC_ARG_WITH([zlib], [AS_HELP_STRING([--with-zlib], [include classes for streaming compressed data in and out @<:@default=check@:>@])], [], [with_zlib=check]) # Check for zlib. HAVE_ZLIB=0 AS_IF([test "$with_zlib" != no], [ AC_MSG_CHECKING([zlib version]) # First check the zlib header version. AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[ #include #if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204) # error zlib version too old #endif ]], [])], [ AC_MSG_RESULT([ok (1.2.0.4 or later)]) # Also need to add -lz to the linker flags and make sure this succeeds. AC_SEARCH_LIBS([zlibVersion], [z], [ AC_DEFINE([HAVE_ZLIB], [1], [Enable classes using zlib compression.]) HAVE_ZLIB=1 ], [ AS_IF([test "$with_zlib" != check], [ AC_MSG_FAILURE([--with-zlib was given, but no working zlib library was found]) ]) ]) ], [ AS_IF([test "$with_zlib" = check], [ AC_MSG_RESULT([headers missing or too old (requires 1.2.0.4)]) ], [ AC_MSG_FAILURE([--with-zlib was given, but zlib headers were not present or were too old (requires 1.2.0.4)]) ]) ]) ]) AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1]) ]) SkyPat-3.2.0/scripts/000077500000000000000000000000001465531052300144225ustar00rootroot00000000000000SkyPat-3.2.0/scripts/.gitignore000066400000000000000000000001061465531052300164070ustar00rootroot00000000000000 compile config.guess config.sub depcomp install-sh ltmain.sh missing SkyPat-3.2.0/utils/000077500000000000000000000000001465531052300140735ustar00rootroot00000000000000SkyPat-3.2.0/utils/autoconf/000077500000000000000000000000001465531052300157115ustar00rootroot00000000000000SkyPat-3.2.0/utils/autoconf/check_skypat.m4000066400000000000000000000032751465531052300206320ustar00rootroot00000000000000dnl dnl @synopsis CHECK_SKYPAT dnl dnl @summary check "skypat" library, and set up variables: dnl SKYPAT_CFLAGS="-I${skypat_path}/include" dnl SKYPAT_CPPFLAGS="-I${skypat_path}/include" dnl SKYPAT_LDFLAGS="-L${skypat_path}/lib -lskypat" dnl dnl This macro is used to check if skypat is already installed in the system. If dnl you want to integrate skypat in your own project, please use SETUP_SKYPAT. dnl dnl Luba Tang dnl AC_DEFUN([CHECK_SKYPAT], [dnl AC_ARG_WITH([skypat], [AS_HELP_STRING([--with-skypat[[=PATH]]], [set up the path of skypat library])], [skypat_path="${withval}"], [skypat_path="${prefix}"]) # Check for skypat. AC_MSG_CHECKING(for "skypat" library) HAVE_SKYPAT=0 AC_LANG_PUSH([C++]) org_CXXFLAGS="${CXXFLAGS}" CXXFLAGS="-I${skypat_path}/include" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[ #include #if !defined(SKYPAT_VERNUM) || (SKYPAT_VERNUM < 0x22) #error skypat version too old #endif ]], [])], [dnl action-if-true AC_MSG_RESULT([ok (2.2 or later)]) ], dnl action-if-true [ dnl action-if-false AS_IF([test "$skypat_path" = "${prefix}" ], [AC_MSG_FAILURE([headers missing or too old (requires >= 2.2)])], [AC_MSG_FAILURE([--with-skypat was given, but skypat headers were not present or were too old (requires >= 2.2)])] ) ]) CXXFLAGS="${org_CXXFLAGS}" AC_LANG_POP([C++]) SKYPAT_CFLAGS="-I${skypat_path}/include" SKYPAT_CPPFLAGS="-I${skypat_path}/include" SKYPAT_LDFLAGS="-L${skypat_path}/lib -lskypat" AC_SUBST(SKYPAT_CFLAGS) AC_SUBST(SKYPAT_CPPFLAGS) AC_SUBST(SKYPAT_LDFLAGS) AM_CONDITIONAL([HAVE_SKYPAT], [test $HAVE_SKYPAT = 1]) ]) SkyPat-3.2.0/utils/autoconf/setup_skypat.m4000066400000000000000000000103201465531052300207020ustar00rootroot00000000000000dnl dnl @synopsis SETUP_SKYPAT([SKYPAT-INSTALL-PATH]) dnl dnl @summary install "skypat" library, and set up variables: dnl SKYPAT_CFLAGS="-I${abs_top_srcdir}/skypat/include" dnl SKYPAT_CPPFLAGS="-I${abs_top_srcdir}/skypat/include" dnl SKYPAT_LDFLAGS="-L${abs_top_builddir}/lib -lskypat" dnl dnl This macro set up Config.h and configuration of the skypat which is installed dnl at [SKYPAT-INSTALL-PATH]. dnl dnl Luba Tang AC_DEFUN([SETUP_SKYPAT], [dnl # Check for skypat. AC_MSG_CHECKING(configure "skypat" library) SKYPAT_PATH=$1 AC_CANONICAL_HOST AC_CACHE_CHECK([type of operating system we're going to host on], [skypat_cv_host_os_type], [case $host in *-*-aix*) skypat_cv_host_os_type="AIX" skypat_cv_host_platform_type="Unix" ;; *-*-irix*) skypat_cv_host_os_type="IRIX" skypat_cv_host_platform_type="Unix" ;; *-*-cygwin*) skypat_cv_host_os_type="Cygwin" skypat_cv_host_platform_type="Unix" ;; *-*-darwin*) skypat_cv_host_os_type="Darwin" skypat_cv_host_platform_type="Unix" ;; *-*-minix*) skypat_cv_host_os_type="Minix" skypat_cv_host_platform_type="Unix" ;; *-*-freebsd*) skypat_cv_host_os_type="FreeBSD" skypat_cv_host_platform_type="Unix" ;; *-*-openbsd*) skypat_cv_host_os_type="OpenBSD" skypat_cv_host_platform_type="Unix" ;; *-*-netbsd*) skypat_cv_host_os_type="NetBSD" skypat_cv_host_platform_type="Unix" ;; *-*-dragonfly*) skypat_cv_host_os_type="DragonFly" skypat_cv_host_platform_type="Unix" ;; *-*-hpux*) skypat_cv_host_os_type="HP-UX" skypat_cv_host_platform_type="Unix" ;; *-*-interix*) skypat_cv_host_os_type="Interix" skypat_cv_host_platform_type="Unix" ;; *-*-linux*) skypat_cv_host_os_type="Linux" skypat_cv_host_platform_type="Unix" ;; *-*-solaris*) skypat_cv_host_os_type="SunOS" skypat_cv_host_platform_type="Unix" ;; *-*-auroraux*) skypat_cv_host_os_type="AuroraUX" skypat_cv_host_platform_type="Unix" ;; *-*-win32*) skypat_cv_host_os_type="Win32" skypat_cv_host_platform_type="Win32" ;; *-*-mingw*) skypat_cv_host_os_type="MingW" skypat_cv_host_platform_type="Win32" ;; *-*-haiku*) skypat_cv_host_os_type="Haiku" skypat_cv_host_platform_type="Unix" ;; *-unknown-eabi*) skypat_cv_host_os_type="Freestanding" skypat_cv_host_platform_type="Unix" ;; *-unknown-elf*) skypat_cv_host_os_type="Freestanding" skypat_cv_host_platform_type="Unix" ;; *) skypat_cv_host_os_type="Unknown" skypat_cv_host_platform_type="Unknown" ;; esac]) dnl Set the "OS" Makefile variable based on the platform type so the dnl makefile can configure itself to specific build hosts if test "$skypat_cv_host_os_type" = "Unknown" ; then AC_MSG_ERROR([Operating system is unknown, configure can't continue]) fi dnl Set the "SKYPAT_ON_*" variables based on llvm_cv_llvm_cv_platform_type dnl This is used by lib/Support to determine the basic kind of implementation dnl to use. case $skypat_cv_host_platform_type in Unix) AC_DEFINE([SKYPAT_ON_UNIX],[1],[Define if this is Unixish platform]) AC_SUBST(SKYPAT_ON_PLATFORM,[SKYPAT_ON_UNIX]) AC_CHECK_HEADERS([sys/time.h]) AC_CHECK_HEADERS([sys/times.h]) AC_SEARCH_LIBS([clock_gettime], [rt], [ AC_DEFINE(HAVE_CLOCK_GETTIME, 1,[Have clock_gettime]) ]) AC_CHECK_FUNCS([gettimeofday]) AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, intptr_t]) AC_CHECK_TYPES([uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t]) AC_CHECK_TYPES([long double, long long, long long int, unsigned long long int]) AC_CHECK_TYPES([off_t, size_t, ssize_t]) AC_TYPE_LONG_DOUBLE_WIDER ;; Win32) AC_DEFINE([SKYPAT_ON_WIN32],[1],[Define if this is Win32ish platform]) AC_SUBST(SKYPAT_ON_PLATFORM,[SKYPAT_ON_WIN32]) ;; esac AC_CONFIG_HEADERS([utils/skypat/include/skypat/Config/Config.h]) skypat_src_path='${abs_top_srcdir}/' skypat_src_path+=${SKYPAT_PATH} skypat_build_path='${abs_top_builddir}/' skypat_build_path+=${SKYPAT_PATH} SKYPAT_CFLAGS="-I${skypat_src_path}/include -I${skypat_build_path}/include" SKYPAT_CPPFLAGS="-I${skypat_src_path}/include -I${skypat_build_path}/include" SKYPAT_LDFLAGS="-L${skypat_build_path}/lib -lskypat" AC_SUBST(SKYPAT_CFLAGS) AC_SUBST(SKYPAT_CPPFLAGS) AC_SUBST(SKYPAT_LDFLAGS) ]) SkyPat-3.2.0/utils/build-script/000077500000000000000000000000001465531052300164745ustar00rootroot00000000000000SkyPat-3.2.0/utils/build-script/README000066400000000000000000000011251465531052300173530ustar00rootroot00000000000000This is a script simplying skypat's building process. ============== Usage -------------- 1. Copy `build.sh` copy this script out of ${SKYPAT_SRC}. For example, if you download skypat source code at /opt/skypat, then you should copy this script in /opt [user@localhost]$ cp ./build.sh ../../../ && cd ../../../ 2. Run `build.sh` You can build `skypat` at three different levels: debug, optimized and normal. The default level is normal. Usage: ./build.sh [skypat source] [dbg|opt|normal] Example: [user@localhost]$ ./build.sh ./skypat dbg or [user@localhost]$ ./build.sh ./skypat SkyPat-3.2.0/utils/build-script/build.sh000077500000000000000000000025001465531052300201270ustar00rootroot00000000000000#!/bin/bash # The SkyPat Project # # This file is distributed under the New BSD License. # See LICENSE for details. # # Note: Must be install libtool first. If you are using Mac OS X, then # try 'brew install libtool'. # # Luba Tang # GGM Kuo function build { local VERSION=$1 local CONFIG=$2 local BUILDDIR=${VERSION}/../build-$(basename $VERSION)-${CONFIG} if [ -d ${BUILDDIR} ]; then rm -rf ${BUILDDIR} fi mkdir ${BUILDDIR} cd ${BUILDDIR} ${VERSION}/autogen.sh if [ "${CONFIG}" = "dbg" ]; then ${VERSION}/configure --prefix=${HOME}/Skymizer/SysRoot --enable-unittest elif [ "${CONFIG}" = "opt" ]; then ${VERSION}/configure --prefix=${HOME}/Skymizer/SysRoot --enable-optimize else ${VERSION}/configure --prefix=${HOME}/Skymizer/SysRoot fi make all install cd - } if [ $# != 2 ] && [ $# != 1 ]; then echo "Usage: $0 [source folder] [dbg|opt|normal]" exit 1; fi # Check if $1 is absolute or relative path. if [[ "$1" = /* ]]; then SRCDIR=$1 else SRCDIR=`pwd`/$1 fi TRGDIR=$2 if [ -z "${TRGDIR}" ]; then TRGDIR="normal" fi if [ "${TRGDIR}" != "dbg" ] && [ "${TRGDIR}" != "opt" ] && [ "${TRGDIR}" != "normal" ]; then echo "Usage: $0 [source folder] [dbg|opt|normal]" exit 1; fi build ${SRCDIR} ${TRGDIR} SkyPat-3.2.0/utils/deb/000077500000000000000000000000001465531052300146255ustar00rootroot00000000000000SkyPat-3.2.0/utils/deb/build-deb.sh000077500000000000000000000001161465531052300170110ustar00rootroot00000000000000#!/bin/sh cd `dirname "$0"`/../../ ./autogen.sh dpkg-buildpackage -rfakeroot