This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/7620 summary logger WIP Change-Id: Icf464430ebb2729b40dc872945d0c311191a671c --- M Common.cfg A libsummarylogger/Makefile A libsummarylogger/Makefile.cfg A libsummarylogger/Makefile.genrules A libsummarylogger/SummaryLogger.cc A libsummarylogger/SummaryLogger.hh 6 files changed, 1,004 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/20/7620/1 diff --git a/Common.cfg b/Common.cfg index bf0a752..d6decbb 100644 --- a/Common.cfg +++ b/Common.cfg @@ -10,7 +10,8 @@ AppendFile := Yes; SourceInfoFormat := Single; LogSourceInfo := Yes; -LoggerPlugins := { JUnitLogger := "libjunitlogger2" } +LoggerPlugins := { JUnitLogger := "libjunitlogger2", + SummaryLogger := "libsummarylogger" } FileMask := LOG_ALL | TTCN_DEBUG | TTCN_MATCHING | DEBUG_ENCDEC; ConsoleMask := ERROR | WARNING | TESTCASE | USER; diff --git a/libsummarylogger/Makefile b/libsummarylogger/Makefile new file mode 100644 index 0000000..ef64c5d --- /dev/null +++ b/libsummarylogger/Makefile @@ -0,0 +1,100 @@ +############################################################################## +# Copyright (c) 2018 sysmocom - s.f.m.c. GmbH +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Neels Hofmeyr +# +############################################################################## +# Makefile for the SummaryLogger plugin. Unfortunately, we'll need four different +# libraries for each plugin... Plugin version information must be +# synchronized with the code. + +TOP := . +include Makefile.cfg + +LIB_DIR := /usr/lib/titan +INCLUDE_DIR := /usr/include/titan + +MAJOR := 0 +MINOR := 0 + +SOURCES := SummaryLogger.cc +STATIC_SOURCES := ${SOURCES} +HEADERS := $(SOURCES:.cc=.hh) +OBJECTS := $(SOURCES:.cc=.o) +OBJECTS_RT2 := $(addprefix FT/,$(OBJECTS)) + +SHARED_LIB := libsummarylogger.so +SHARED_LIB_RT2 := libsummarylogger-rt2.so +SHARED_LIB_PARALLEL := libsummarylogger-parallel.so +SHARED_LIB_PARALLEL_RT2 := libsummarylogger-parallel-rt2.so + +CPPFLAGS += -I$(INCLUDE_DIR) + +CXXFLAGS += -I$(INCLUDE_DIR) -DLINUX + +LDFLAGS_ORIG := $(LDFLAGS) +LDFLAGS += -g -L/usr/lib/titan -Wl,-soname,$(SHARED_LIB).$(MAJOR) -o $(SHARED_LIB).$(MAJOR).$(MINOR) +LDFLAGS_RT2 += $(LDFLAGS_ORIG) -g -L$(LIB_DIR) -Wl,-soname,$(SHARED_LIB_RT2).$(MAJOR) -o $(SHARED_LIB_RT2).$(MAJOR).$(MINOR) +LDFLAGS_PARALLEL += $(LDFLAGS_ORIG) -g -L$(LIB_DIR) -Wl,-soname,$(SHARED_LIB_PARALLEL).$(MAJOR) -o $(SHARED_LIB_PARALLEL).$(MAJOR).$(MINOR) +LDFLAGS_PARALLEL_RT2 += $(LDFLAGS_ORIG) -g -L$(LIB_DIR) -Wl,-soname,$(SHARED_LIB_PARALLEL_RT2).$(MAJOR) -o $(SHARED_LIB_PARALLEL_RT2).$(MAJOR).$(MINOR) + +LIBS := -lttcn3-dynamic +LIBS_RT2 := -lttcn3-rt2-dynamic +LIBS_PARALLEL := -lttcn3-parallel-dynamic +LIBS_PARALLEL_RT2 := -lttcn3-rt2-parallel-dynamic + +TARGETS := $(SHARED_LIB) $(SHARED_LIB_PARALLEL) $(SHARED_LIB_RT2) $(SHARED_LIB_PARALLEL_RT2) +# .so with .major appended: +TARGETS_MAJOR := $(addsuffix .$(MAJOR), $(TARGETS)) +# .so with .major.minor appended: +TARGETS_MAJOR_MINOR := $(addsuffix .$(MINOR), $(TARGETS_MAJOR)) + +# OBJECTS_RT2, TARGETS_MAJOR and TARGETS_MAJOR_MINOR are non-standard make variables, +# not taken into account by "clean" in Makefile.genrules +# Delete them as "miscellaneous" files. +TOBECLEANED := $(OBJECTS_RT2) $(TARGETS_MAJOR) $(TARGETS_MAJOR_MINOR) + +all run: $(TARGETS) + +$(SHARED_LIB): $(OBJECTS) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $? $(LIBS) -shared + ln -sf $@.$(MAJOR).$(MINOR) $@.$(MAJOR) + ln -sf $@.$(MAJOR) $@ + +$(SHARED_LIB_RT2): $(OBJECTS_RT2) + $(CXX) $(CPPFLAGS_RT2) $(CXXFLAGS) $(LDFLAGS_RT2) $? $(LIBS_RT2) -shared + ln -sf $@.$(MAJOR).$(MINOR) $@.$(MAJOR) + ln -sf $@.$(MAJOR) $@ + +$(SHARED_LIB_PARALLEL): $(OBJECTS) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS_PARALLEL) $? $(LIBS_PARALLEL) -shared + ln -sf $@.$(MAJOR).$(MINOR) $@.$(MAJOR) + ln -sf $@.$(MAJOR) $@ + +$(SHARED_LIB_PARALLEL_RT2): $(OBJECTS_RT2) + $(CXX) $(CPPFLAGS_RT2) $(CXXFLAGS) $(LDFLAGS_PARALLEL_RT2) $? $(LIBS_PARALLEL_RT2) -shared + ln -sf $@.$(MAJOR).$(MINOR) $@.$(MAJOR) + ln -sf $@.$(MAJOR) $@ + +$(OBJECTS): $(SOURCES) $(HEADERS) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $? + +# The `-o $@' stuff is necessary, otherwise the result will be put into the +# current directory. +$(OBJECTS_RT2): $(SOURCES) + mkdir -p FT + $(CXX) $(CPPFLAGS_RT2) $(CXXFLAGS) -c $? -o $@ + +dep: + @echo Doing nothing... + +install: $(SHARED_LIB) $(SHARED_LIB_RT2) $(SHARED_LIB_PARALLEL) $(SHARED_LIB_PARALLEL_RT2) + mkdir -p $(LIB_DIR) + cp $(SHARED_LIB)* $(SHARED_LIB_RT2)* $(SHARED_LIB_PARALLEL)* $(SHARED_LIB_PARALLEL_RT2)* $(LIB_DIR) + +include Makefile.genrules diff --git a/libsummarylogger/Makefile.cfg b/libsummarylogger/Makefile.cfg new file mode 100644 index 0000000..4b5d15f --- /dev/null +++ b/libsummarylogger/Makefile.cfg @@ -0,0 +1,406 @@ +############################################################################### +# Copyright (c) 2000-2017 Ericsson Telecom AB +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Baji, Laszlo +# Balasko, Jeno +# Baranyi, Botond +# Beres, Szabolcs +# Delic, Adam +# Feher, Csaba +# Forstner, Matyas +# Kovacs, Ferenc +# Kremer, Peter +# Lovassy, Arpad +# Ormandi, Matyas +# Pandi, Krisztian +# Raduly, Csaba +# Szabados, Kristof +# Szabo, Janos Zoltan – initial implementation +# Szalai, Endre +# Zalanyi, Balazs Andor +# +############################################################################### +ifndef TOP +$(error please define TOP) +endif + +# Configurations for the Free Open Source Software version, if available +ifneq ($(wildcard $(TOP)/MakefileFOSS.cfg), ) + include $(TOP)/MakefileFOSS.cfg +else + # Set whether licensing is enabled: (yes or no) + LICENSING := yes + + # Set whether to send usage statistics: (yes or no) + USAGE_STATS := yes +endif + +# Define SRCDIR to the root of Titan sources to enable out-of-tree build +#SRCDIR := ${HOME}/workspace/TTCNv3 + +# Set these variables to fit your system: + +# The target directory where the Test Executor will be installed to: +TTCN3_DIR := /usr/lib/titan + +# New installed files are run from make install, so they are added to the PATH +PATH := ${PATH}:${TTCN3_DIR}/bin + +# Set it to 'yes' for developing or 'no' for release. +DEBUG := no + +# Set it to 'yes' to generate coverage data (requires DEBUG=yes) +COVERAGE := no + +# Set it to 'yes' to enable extra features for the debugger UI in single mode +# (this requires an extra library when linking the generated code). +# Set it to 'no' to use a simplified debugger UI. +ADVANCED_DEBUGGER_UI := no + +# Your platform. Allowed values: SOLARIS, SOLARIS8, LINUX, FREEBSD, +# WIN32. Decided automagically if not defined (recommended). +# PLATFORM := + +# Uncomment the following for "native" Win32 +#MINGW := -DMINGW -mno-cygwin + +# Utility for building lexical analyzers (tokenizers): +FLEX := flex + +# Utility for building parsers: +BISON := bison + +# The C compiler used for building: +CC := gcc + +# The C++ compiler used for building: +CXX := g++ + +# generate userguide at install ('make release' always generates it) +GEN_PDF := no + +# Set whether to build the CLI for MC: (yes or no) +CLI := yes + +# set whether to build the JNI native library: (yes or no) +JNI := yes + +# Build the LTTng-UST logger plugin +LTTNGUSTLOGGER := no + +# Path of the Java Developement Kit installation +# (must be at least version 1.5.0_10) +JDKDIR := /usr/lib/jvm/default-java + +# Path of OpenSSL installation: (always required) +OPENSSL_DIR := default + +# Location of libxml2 +XMLDIR := default + +# Flags for the C(++) preprocessor: +# Prevent a warning about yyinput being defined but not used +CPPFLAGS += -DYY_NO_INPUT + +# Flags shared between C and C++ +COMPILERFLAGS := -Wall + +# 'Hardcore' settings +# Unlikely to work for GCC below 4.x +#COMPILERFLAGS += -Werror -pedantic -W -Wno-unused-parameter -O1 + +# Flags for the C compiler. +# std=gnu9x shuts up warnings about long long and variadic macros +CCFLAGS += $(COMPILERFLAGS) -std=gnu9x + +# Flags for the C++ compiler: +CXXFLAGS += $(COMPILERFLAGS) -Wno-long-long + +# The command for maintaining static libraries: +AR := ar + +# The command for building the shared libraries: +# It shall be set to either "$(CXX) -G" or "$(CXX) -shared" depending +# on the linker you use. +LD = $(CXX) -shared + +# Flags for linking binary executables (e.g. for profiling): +LDFLAGS += $(MINGW) + +# The command for removing symbol table from the executables: +STRIP := strip + +# Flags for flex: +FLEXFLAGS := -B -s -Cr + +# Flags for bison: +BISONFLAGS := -d + +# Override common settings with personal preferences if needed +-include $(TOP)/Makefile.personal + +## ## ## ## ## Variables below are automatically set ## ## ## ## ## + +ifeq ($(DEBUG), yes) + CPPFLAGS += -DMEMORY_DEBUG -DFATAL_DEBUG +else + CPPFLAGS += -DNDEBUG +endif + +# MingW flags need to be passed to the preprocessor during ctags configure +CPPFLAGS += $(MINGW) + +ifeq ($(DEBUG), yes) + CCFLAGS += -g + CCFLAGS += -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align \ + -Wstrict-prototypes +else +ifeq ($(COVERAGE), yes) + CCFLAGS += -O0 +else + CCFLAGS += -O2 +endif +endif + +# Only the default Cygwin compiler can be used for Mingw. +# Its version is 3.4.4, too low. +ifndef MINGW +# Only GCC 4.x understands -Wno-variadic-macros, comment out for lower versions +#CXXFLAGS += -Wno-variadic-macros +endif + +ifeq ($(DEBUG), yes) + CXXFLAGS += -g + CXXFLAGS += -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align +else +ifeq ($(COVERAGE), yes) + CXXFLAGS += -O0 +else + CXXFLAGS += -O2 +endif +endif + +# Flags for the C/C++ compilers to generate dependency list (-M or -MM +# for gcc or clang, -xM or -xM1 for Sun C compiler). + +ifneq ($(filter gcc% clang%, $(notdir $(CC))),) +CCDEPFLAG := -MM +CXXDEPFLAG := -MM +else +# Let's hope it's the Sun compiler +CCDEPFLAG := -xM1 +CXXDEPFLAG := -xM1 +endif + +ifeq ($(DEBUG), yes) + LDFLAGS += -g +endif + + +ifeq ($(DEBUG), yes) + FLEXFLAGS += -b -p +# FLEXFLAGS += -d +else +# Comment out the line below if flex version 2.5.4[a] is used. +# This version does not support optimized tables together with yylineno. + FLEXFLAGS += -Cfe +endif + + +ifeq ($(DEBUG), yes) + BISONFLAGS += -t -v +endif + +ifeq ($(COVERAGE), yes) + CPPFLAGS += -DCOVERAGE_BUILD + COMPILERFLAGS += -fprofile-arcs -ftest-coverage + LDFLAGS += -fprofile-arcs -ftest-coverage -lgcov +endif + +ifeq ($(ADVANCED_DEBUGGER_UI), yes) + CPPFLAGS += -DADVANCED_DEBUGGER_UI +endif + +# Directory which contains the code for POSIX regular expression handling. +# It is needed on platforms where the system's libc does not support POSIX +# regexps. This is the case for Mingw. +ifdef MINGW +# If your platform isn't Mingw but lacks POSIX regular expressions, +# comment out the ifdef/endif +REGEX_DIR := /mnt/TTCN/Tools/CPP/regex-glibc-2.5.1 +endif + +# Warning! Never set the above directories to /usr. +# If your OpenSSL, Qt is installed under /usr you'd better set +# these variables to a fake (non-existent) directory. If this is the case, +# gcc will find the required headers and libs anyway, but -I/usr/include +# might confuse it. + +# This is especially true on Windows with Mingw installed as a Cygwin package. +# -mno-cygwin alters the include serach path to find the Mingw headers. +# Passing -I/usr/include would cause the Mingw compiler to read the Cygwin +# headers, and the compilation will fail. + +# The path name where the LaTeX binaries can be found. (optional) +# If this variable is not defined the User Documentation will not be built +# or installed. +TEXPATH := /usr/local/teTeX2.0.2/bin/sparc-sun-solaris2.8 + + +########################################################################### +# You don't have to alter anything below this line. + +# Setting PLATFORM automagically if it is not defined. +ifndef PLATFORM +PLATFORM1 := $(shell uname -s) +PLATFORM2 := $(shell uname -r) +PLATFORM3 := $(shell uname -m) +ifeq ($(PLATFORM1), SunOS) + ifneq ($(PLATFORM2), 5.6) + PLATFORM := SOLARIS8 + PLATSUFFIX = -sol8 + else + PLATFORM := SOLARIS + PLATSUFFIX = -sol6 + endif # 5.8 +endif # SunOS +ifeq ($(PLATFORM1), Linux) + PLATFORM := LINUX + PLATSUFFIX = -linux +endif # Linux +ifeq ($(PLATFORM1), FreeBSD) + PLATFORM := FREEBSD +endif # FreeBSD +ifeq ($(findstring CYGWIN, $(PLATFORM1)), CYGWIN) + PLATFORM := WIN32 + PLATSUFFIX = -cygwin +endif # CYGWIN +endif # ifndef PLATFORM +ifndef PLATFORM + PLATFORM := $(error PLEASE CHECK THE PLATFORM SETTINGS) +endif # ifndef PLATFORM + +# Derived variables, which you should never change. + +ifdef MINGW + +# Target directory for binaries: +BINDIR := $(TTCN3_DIR)/programs +# Target directory for manual pages: +MANDIR := $(TTCN3_DIR)/manuals +# Target directory for other files (nedit/xemacs additions, etc.) +ETCDIR := $(TTCN3_DIR) + +else + +# Target directory for binaries: +BINDIR := $(TTCN3_DIR)/bin +# Target directory for manual pages: +MANDIR := $(TTCN3_DIR)/man +# Target directory for other files (nedit/xemacs additions, etc.) +ETCDIR := $(TTCN3_DIR)/etc + +endif + +# Target directory for header files: +INCDIR := $(TTCN3_DIR)/include +# Target directory for libraries: +LIBDIR := $(TTCN3_DIR)/lib +# Target directory for html help pages: +HELPDIR := $(TTCN3_DIR)/help +# Target directory for the documentation: +DOCDIR := $(TTCN3_DIR)/doc +# Target directory for the demo "Hello World!" +DEMODIR := $(TTCN3_DIR)/demo + +CPPFLAGS += -D$(PLATFORM) + +ifeq ($(LICENSING), yes) + CPPFLAGS += -DLICENSE + LICENSE_LIBS = -L$(OPENSSL_DIR)/lib -lcrypto +else + LICENSE_LIBS := +endif + +ifeq ($(USAGE_STATS), yes) + CPPFLAGS += -DUSAGE_STATS +endif + +# Windows/Cygwin specific settings +ifeq ($(PLATFORM), WIN32) + EXESUFFIX := .exe + LDFLAGS += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc + + ifdef MINGW + MINGW_LIBS := -lgdi32 + endif +else + EXESUFFIX := + + ifdef MINGW + $(error MingW not supported on $(PLATFORM)) + endif + + CCFLAGS += -fPIC + CXXFLAGS += -fPIC + LDFLAGS += -fPIC +endif + +# Try to use -isystem for Qt headers (this is a GCC feature). +# This avoids the myriads of warnings issued for the Qt headers. +ifneq (,$(findstring SOLARIS,$(PLATFORM))) +# Avoid using it on Solaris, because +# -isystem puts an implicit "extern C" around every system header, +# which causes compilation of Qt headers to fail miserably :-( +# (this could be fixed by recompiling GCC) + INCLUDEQT := -I +else +# Not Solaris + INCLUDEQT := -isystem +endif + +# Setting EPOLL usage - It is Linux specific +ifeq ($(PLATFORM), LINUX) + CPPFLAGS += -DUSE_EPOLL +endif + +ifdef ALPINE_LINUX + CPPFLAGS += -DALPINE_LINUX +endif + +#not useful in compiler2/asn1, for example +#REL_DIR := $(notdir $(CURDIR)) + +export ABS_TOP := $(abspath $(TOP))/ +ifeq "$(ABS_TOP)" "/" +# abspath only from GNU make 3.81, here's a replacement +ABS_TOP := $(shell cd $(TOP); pwd)/ +endif + +ifdef SRCDIR + +REL_DIR := $(subst $(ABS_TOP),,$(CURDIR)) + +ABS_SRC := $(SRCDIR)/$(REL_DIR) + +CPPFLAGS += -I. -I$(ABS_SRC) + +SRC_TOP := $(SRCDIR) + +else + +ABS_SRC := $(abspath $(CURDIR)) +ifeq "$(ABS_SRC)" "" +ABS_SRC := $(shell cd $(CURDIR); pwd) +endif + +SRC_TOP := $(TOP) + +endif + + diff --git a/libsummarylogger/Makefile.genrules b/libsummarylogger/Makefile.genrules new file mode 100644 index 0000000..f52054b --- /dev/null +++ b/libsummarylogger/Makefile.genrules @@ -0,0 +1,174 @@ +############################################################################# +# Copyright (c) 2000-2017 Ericsson Telecom AB +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Balasko, Jeno +# Baranyi, Botond +# Forstner, Matyas +# Kovacs, Ferenc +# Pandi, Krisztian +# Raduly, Csaba +# Szabo, Janos Zoltan – initial implementation +# +############################################################################## +# General stuff (to be included at the end of makefiles). The +# following variables are used: DEPFILES, SUBDIRS... + +tags: $(SOURCES) +ifdef SUBDIRS + @for i in $(SUBDIRS) ; do \ + (cd $$i && $(MAKE) tags) || exit 1; \ + done +endif + etags --members *.hh *.h *.c *.cc + +dep: +ifdef SUBDIRS + @for i in $(SUBDIRS) ; do \ + (cd $$i && $(MAKE) dep) || exit 1; \ + done +endif +ifdef DEPFILES + $(MAKE) $(DEPFILES) +endif + +clean: +ifdef SUBDIRS + @for i in $(SUBDIRS) ; do \ + (cd $$i && $(MAKE) clean) || exit 1; \ + done +endif + $(RM) $(TARGETS) $(OBJECTS) $(TOBECLEANED) + +distclean: +ifdef SUBDIRS + @for i in $(SUBDIRS) ; do \ + (cd $$i && $(MAKE) distclean) || exit 1; \ + done +endif + $(RM) $(TARGETS) $(OBJECTS) $(TOBECLEANED) \ + $(GENERATED_HEADERS) $(GENERATED_SOURCES) \ + $(GENERATED_OTHERS) \ + $(DEPFILES) TAGS *.gcno *.gcda + +# This target allows us to "make ../clean" +../% $(foreach dir, $(SUBDIRS), $(dir)/%): + cd $(dir $@) && $(MAKE) $(notdir $@) + +# General rules to compile C(++) files. +# +# These macros implement "silent" rules during building. +# Define the V make variable or environment variable to a nonzero value to get +# the exact call to the compiler: e.g. make V=1 +# +# Define the VD variable to get the exact (verbose) action while +# generating dependencies. +# +NULL := +SPACE := ${NULL} ${NULL} + +DEF_V := 0 +DEF_VD:= 0 + +V_CC_0 = @echo " (CC) " $<;$(SPACE) +V_CXX_0 = @echo " (C++) " $<;$(SPACE) +V_DEP_0 = @echo " (dep) " $<;$(SPACE) + +V_CC_ = $(V_CC_$(DEF_V)) +V_CXX_ = $(V_CXX_$(DEF_V)) +V_DEP_ = $(V_DEP_$(DEF_VD)) + +V_CC = $(V_CC_$(V)) +V_CXX = $(V_CXX_$(V)) +V_DEP = $(V_DEP_$(VD)) + +%.o: %.c + $(V_CC)$(CC) -c $(CPPFLAGS) $(CCFLAGS) $< -o $@ + +# Special rule for building profmerge files +%.profmerge.o: %.cc + $(V_CXX)$(CXX) -c -DPROF_MERGE $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + +%.o: %.cc + $(V_CXX)$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + +# Preprocess C/C++ files +%.i: %.c + $(CC) -E $(CPPFLAGS) $(CCFLAGS) \ + $< > $@ + +%.ii: %.cc + $(CXX) -E $(CPPFLAGS) $(CXXFLAGS) \ + $< > $@ + +# General rules to create the dependency file. + +%.d: %.c + $(V_DEP)set -e; $(CC) $(CCDEPFLAG) $(CPPFLAGS) $< \ + | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@; \ + [ -s $@ ] || rm -f $@ + +%.d: %.cc + $(V_DEP)set -e; $(CXX) $(CXXDEPFLAG) $(CPPFLAGS) $< \ + | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@; \ + [ -s $@ ] || rm -f $@ + +ifdef DEPFILES + ifndef MAKECMDGOALS + DEPFILES_NEEDED := yes + else + DEPFILES_NEEDED := $(filter-out clean distclean, $(MAKECMDGOALS)) + endif + ifdef DEPFILES_NEEDED + DEPFILES_INCLUDE := $(filter-out $(MAKECMDGOALS), $(DEPFILES)) + ifdef DEPFILES_INCLUDE + ifeq (,$(findstring n,$(MAKEFLAGS))) + # -n was *not* given to make + -include $(DEPFILES_INCLUDE) + endif + endif + endif +endif + +# Building PDFs from man pages (for MinGW) +%.pdf: %.1 + man2pdf ./$< $@ +# The "./" prefix is important, it tells man that the input is a filename, +# so it shouldn't search through MANPATH. + +# List of fake targets: +.PHONY: all install tags dep clean distclean + +# Disable all built-in suffix rules of make +.SUFFIXES: + +# Do not delete generated headers while building .d files +# (.PRECIOUS would also keep them if make is killed) +.SECONDARY: $(GENERATED_HEADERS) + +ifdef SRCDIR + +REQUIRED_MAKE_VERSION = 3.81 +# 3.80 is known not to work; 3.82 does work +REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION)) +EARLIER_MAKE_VERSION = $(firstword $(sort $(REAL_MAKE_VERSION) $(REQUIRED_MAKE_VERSION))) +ifeq "$(REQUIRED_MAKE_VERSION)" "$(EARLIER_MAKE_VERSION)" + +# Declare a search path for every source. +# "vpath %.cc $(ABS_SRC)" would lump in generated .cc files, +# potentially picking up generated files laying around in the source dir +# instead of generating them in the build dir. +$(foreach src, $(STATIC_SOURCES) $(ORIGINATORS), $(eval vpath $(src) $(ABS_SRC))) + +else + +# alas, make 3.80 can't cope with the "foreach/eval vpath" above +#$(warning no OOBE with make $(MAKE_VERSION)) + +endif + +endif diff --git a/libsummarylogger/SummaryLogger.cc b/libsummarylogger/SummaryLogger.cc new file mode 100644 index 0000000..9cadb55 --- /dev/null +++ b/libsummarylogger/SummaryLogger.cc @@ -0,0 +1,226 @@ +/****************************************************************************** + * Copyright (c) 2018 sysmocom - s.f.m.c. GmbH + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Neels Hofmeyr + * + ******************************************************************************/ +#include "SummaryLogger.hh" + +#include <unistd.h> +#include <sys/types.h> + +#include <sys/time.h> + +extern "C" { + ILoggerPlugin *create_plugin() { return new SummaryLogger(); } + void destroy_plugin(ILoggerPlugin *plugin) { delete plugin; } +} + + +TestCase::TestCase() +{ + reset(); +} + +void TestCase::reset() +{ + verdict = Unbound; + expected_verdict = Skipped; + tc_name = ""; + module_name = ""; +} + +TestSuite::~TestSuite() +{ + for (TestCases::const_iterator it = testcases.begin(); it != testcases.end(); ++it) { + delete (*it); + } +} + +SummaryLogger::SummaryLogger() + : filename_stem_(NULL), testsuite_name_(mcopystr("Titan")), out_filename_(NULL), file_stream_(NULL) +{ + major_version_ = 1; + minor_version_ = 0; + name_ = mcopystr("SummaryLogger"); + help_ = mcopystr("SummaryLogger writes a brief summary, keeping track of expected-to-fail items"); +} + +SummaryLogger::~SummaryLogger() +{ + close_file(); + + Free(name_); + Free(help_); + Free(out_filename_); + Free(testsuite_name_); + Free(filename_stem_); + name_ = help_ = out_filename_ = filename_stem_ = NULL; + file_stream_ = NULL; +} + +void SummaryLogger::init(const char *) +{ + fprintf(stderr, "Initializing `%s' (v%u.%u): %s\n", name_, major_version_, minor_version_, help_); +} + +void SummaryLogger::fini() +{ +} + +void SummaryLogger::set_parameter(const char *parameter_name, const char *parameter_value) +{ + if (!strcmp("filename_stem", parameter_name)) { + if (filename_stem_ != NULL) + Free(filename_stem_); + filename_stem_ = mcopystr(parameter_value); + } else if (!strcmp("testsuite_name", parameter_name)) { + if (filename_stem_ != NULL) + Free(testsuite_name_); + testsuite_name_ = mcopystr(parameter_value); + } else { + fprintf(stderr, "Unsupported parameter: `%s' with value: `%s'\n", + parameter_name, parameter_value); + } +} + +void SummaryLogger::open_file(bool is_first) { + if (is_first) { + if (filename_stem_ == NULL) { + filename_stem_ = mcopystr("summary"); + } + } + + if (file_stream_ != NULL) + return; + + if (!TTCN_Runtime::is_single() && !TTCN_Runtime::is_mtc()) + return; // don't bother, only MTC has testcases + + out_filename_ = mprintf("%s-%lu.log", filename_stem_, (unsigned long)getpid()); + + file_stream_ = fopen(out_filename_, "w"); + if (!file_stream_) { + fprintf(stderr, "%s was unable to open log file `%s', reinitialization " + "may help\n", plugin_name(), out_filename_); + return; + } + + is_configured_ = true; + testsuite.ts_name = testsuite_name_; +} + +void SummaryLogger::close_file() { + if (file_stream_ != NULL) { + testsuite.write(file_stream_); + fclose(file_stream_); + file_stream_ = NULL; + } + if (out_filename_) { + Free(out_filename_); + out_filename_ = NULL; + } +} + +void SummaryLogger::log(const TitanLoggerApi::TitanLogEvent& event, + bool /*log_buffered*/, bool /*separate_file*/, + bool /*use_emergency_mask*/) +{ + if (file_stream_ == NULL) return; + + const TitanLoggerApi::LogEventType_choice& choice = event.logEvent().choice(); + + switch (choice.get_selection()) { + case TitanLoggerApi::LogEventType_choice::ALT_testcaseOp: + { + const TitanLoggerApi::TestcaseEvent_choice& tcev = choice.testcaseOp().choice(); + + switch (tcev.get_selection()) { + case TitanLoggerApi::TestcaseEvent_choice::ALT_testcaseStarted: + testcase.tc_name = tcev.testcaseStarted().testcase__name(); + // remember the start time + testcase.verdict = TestCase::Unbound; + break; + + case TitanLoggerApi::TestcaseEvent_choice::ALT_testcaseFinished: + { + const TitanLoggerApi::TestcaseType& tct = tcev.testcaseFinished(); + testcase.module_name = tct.name().module__name(); + + testcase.setTCVerdict(event); + testsuite.addTestCase(testcase); + testcase.reset(); + break; + } + + case TitanLoggerApi::TestcaseEvent_choice::UNBOUND_VALUE: + testcase.verdict = TestCase::Unbound; + break; + } + + break; + } + + default: + break; + } + + fflush(file_stream_); +} + +void TestCase::writeTestCase(FILE* file_stream_) const{ + fprintf(file_stream_, "%s.%s: %s\n", module_name.data(), tc_name.data(), verdict); + fflush(file_stream_); +} + +void TestSuite::addTestCase(const TestCase& testcase) { + testcases.push_back(new TestCase(testcase)); + all++; + + if (testcase.verdict == TestCase::Fail) failed++; + else if (testcase.verdict == TestCase::Skipped) skipped++; + else if (testcase.verdict == TestCase::Error) error++; + else if (testcase.verdict == TestCase::Inconc) inconc++; +} + +void TestSuite::write(FILE* file_stream_) { + for (TestCases::const_iterator it = testcases.begin(); it != testcases.end(); ++it) { + (*it)->writeTestCase(file_stream_); + } + fflush(file_stream_); +} + +void TestCase::setTCVerdict(const TitanLoggerApi::TitanLogEvent& event){ + TitanLoggerApi::Verdict tc_verdict = event.logEvent().choice().testcaseOp().choice().testcaseFinished().verdict(); + switch (tc_verdict) { + case TitanLoggerApi::Verdict::UNBOUND_VALUE: + case TitanLoggerApi::Verdict::UNKNOWN_VALUE: + verdict = TestCase::Unbound; + break; + + case TitanLoggerApi::Verdict::v0none: + verdict = TestCase::Skipped; + break; + + case TitanLoggerApi::Verdict::v1pass: + verdict = TestCase::Pass; + break; + + case TitanLoggerApi::Verdict::v2inconc: + verdict = TestCase::Inconc; + break; + + case TitanLoggerApi::Verdict::v3fail: + verdict = TestCase::Fail; + break; + + case TitanLoggerApi::Verdict::v4error: + verdict = TestCase::Error; + break; + } +} diff --git a/libsummarylogger/SummaryLogger.hh b/libsummarylogger/SummaryLogger.hh new file mode 100644 index 0000000..c1631e8 --- /dev/null +++ b/libsummarylogger/SummaryLogger.hh @@ -0,0 +1,96 @@ +/****************************************************************************** + * Copyright (c) 2018 sysmocom - s.f.m.c. GmbH + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Neels Hofmeyr + * + ******************************************************************************/ +#ifndef SummaryLogger_HH2 +#define SummaryLogger_HH2 + +namespace TitanLoggerApi { class TitanLogEvent; } + +#ifndef TITAN_RUNTIME_2 +#include "RT1/TitanLoggerApi.hh" +#else +#include "RT2/TitanLoggerApi.hh" +#endif + +#include "ILoggerPlugin.hh" +#include <stdio.h> +#include <string> +#include <vector> + +struct TestCase { + static constexpr const char* Pass = "pass"; + static constexpr const char* Inconc = "INCONCLUSIVE"; + static constexpr const char* Fail = "FAIL"; + static constexpr const char* Error = "ERROR"; + static constexpr const char* Unbound = "UNBOUND"; + static constexpr const char* Skipped = "skipped"; + + const char *expected_verdict; + const char *verdict; + std::string tc_name; + std::string module_name; + + TestCase(); + + void writeTestCase(FILE* file_stream_) const; + void setTCVerdict(const TitanLoggerApi::TitanLogEvent& event); + void reset(); +}; + + +struct TestSuite { + typedef std::vector<TestCase*> TestCases; + + std::string ts_name; + int all; + int skipped; + int failed; + int error; + int inconc; + TestCases testcases; + + TestSuite():ts_name(""), all(0), skipped(0), failed(0), error(0), inconc(0) {} + ~TestSuite(); + + void addTestCase(const TestCase& element); + void write(FILE* file_stream_); +}; + +class SummaryLogger: public ILoggerPlugin +{ + public: + SummaryLogger(); + virtual ~SummaryLogger(); + inline bool is_static() { return false; } + void init(const char *options = 0); + void fini(); + + void log(const TitanLoggerApi::TitanLogEvent& event, bool log_buffered, + bool separate_file, bool use_emergency_mask); + void set_parameter(const char *parameter_name, const char *parameter_value); + + virtual void open_file(bool is_first); + virtual void close_file(); + + private: + // parameters + char *filename_stem_; + char *testsuite_name_; + // working values + char *out_filename_; + char *expect_filename_; + TestSuite testsuite; + TestCase testcase; + + FILE *file_stream_; +}; + +#endif // SummaryLogger_HH2 -- To view, visit https://gerrit.osmocom.org/7620 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icf464430ebb2729b40dc872945d0c311191a671c Gerrit-PatchSet: 1 Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>