Skip to content
Snippets Groups Projects
Commit b7aa9eef authored by Luka Stanisic's avatar Luka Stanisic
Browse files

Merge branch 'add_ci' into 'master'

Add CI

See merge request !1
parents c30950f8 0ee77a62
Branches
Tags
1 merge request!1Add CI
Pipeline #63114 passed
# use MPCDF module environment
image: gitlab-registry.mpcdf.mpg.de/mpcdf/module-image
default:
before_script:
- module load cmake git
test-gcc9:
script:
- module load gcc/9
- CC=gcc CXX=g++ CXXFLAGS="-std=c++11" ./get_gtest.sh
- make CC=gcc CXX=g++ CXXFLAGS="-std=c++11 -I$PWD/googletest/install/include" LDFLAGS="-L$PWD/googletest/install/lib64"
test-intel19:
script:
- module load intel/19.0.4
- CC=icc CXX=icpc CXXFLAGS="-std=c++11" ./get_gtest.sh
- make CC=icc CXX=icpc CXXFLAGS="-std=c++11 -I$PWD/googletest/install/include" LDFLAGS="-L$PWD/googletest/install/lib64"
SRC=src/main.cpp
TESTS=tests
COV=coverage
OUT_T=test_output
OUT_E=expected_output
APP=program
CXX=g++
BROWSER=google-chrome
TESTS=tests
TEST_APP=runTests
TEST_SRC=$(TESTS)/test_funcs.cpp
LDFLAGS_GTEST=-lgtest -lpthread
# Default
all: distclean compile test
# Compiling section
compile:
$(CXX) -o $(APP) $(SRC)
$(CXX) $(CXXFLAGS) -o $(APP) $(SRC)
compile_coverage:
$(CXX) -o $(APP) --coverage $(SRC)
$(CXX) $(CXXFLAGS) -o $(APP) --coverage $(SRC)
# Testing section
test: simple_tests regression_test unit_tests
......@@ -31,8 +34,9 @@ regression_test:
diff $(OUT_T) $(OUT_E)
unit_tests:
cd $(TESTS) && cmake CMakeLists.txt && make
./$(TESTS)/runTests
$(CXX) $(CXXFLAGS) -o test_funcs.o -c $(TEST_SRC)
$(CXX) $(CXXFLAGS) test_funcs.o -o $(TEST_APP) $(LDFLAGS) $(LDFLAGS_GTEST)
./$(TEST_APP)
# Coverage section
coverage: clean clean_coverage compile_coverage simple_tests
......@@ -50,7 +54,7 @@ clean:
rm -f $(APP)
clean_tests:
rm -rf $(TESTS)/CMakeFiles $(TESTS)/CMakeCache.txt $(TESTS)/cmake_install.cmake $(TESTS)/CMakeFiles $(TESTS)/runTests $(OUT_E) $(OUT_T)
rm -rf $(TESTS)/CMakeFiles $(TESTS)/CMakeCache.txt $(TESTS)/cmake_install.cmake $(TESTS)/CMakeFiles $(TESTS)/runTests $(OUT_E) $(OUT_T) $(TEST_APP) *.o
clean_coverage:
rm -rf *.gcno *.gcda $(APP).info $(COV)
......
#!/bin/bash
# already there
[[ -d googletest ]] && exit 0
# otherwise download and build
git clone https://github.com/google/googletest.git
mkdir -p googletest/build
cd googletest/build
cmake .. -DCMAKE_INSTALL_PREFIX=../install
make && make install
#include <stdio.h>
#include <stdlib.h>
#include "funcs.cpp"
using namespace std;
......
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.12
# Default target executed when no arguments are given to make.
default_target: all
.PHONY : default_target
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
.NOTPARALLEL:
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =
.SUFFIXES: .hpux_make_needs_suffix_list
# Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake
# The command to remove a file.
RM = /usr/bin/cmake -E remove -f
# Escaping for special characters.
EQUALS = =
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /home/sluka/Work/testing_example/tests
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /home/sluka/Work/testing_example/tests
#=============================================================================
# Targets provided globally by CMake.
# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
/usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache
# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast
# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
/usr/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : edit_cache
# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast
# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /home/sluka/Work/testing_example/tests/CMakeFiles /home/sluka/Work/testing_example/tests/CMakeFiles/progress.marks
$(MAKE) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start /home/sluka/Work/testing_example/tests/CMakeFiles 0
.PHONY : all
# The main clean target
clean:
$(MAKE) -f CMakeFiles/Makefile2 clean
.PHONY : clean
# The main clean target
clean/fast: clean
.PHONY : clean/fast
# Prepare targets for installation.
preinstall: all
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall
# Prepare targets for installation.
preinstall/fast:
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast
# clear depends
depend:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend
#=============================================================================
# Target rules for targets named runTests
# Build rule for target.
runTests: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 runTests
.PHONY : runTests
# fast build rule for target.
runTests/fast:
$(MAKE) -f CMakeFiles/runTests.dir/build.make CMakeFiles/runTests.dir/build
.PHONY : runTests/fast
test_funcs.o: test_funcs.cpp.o
.PHONY : test_funcs.o
# target to build an object file
test_funcs.cpp.o:
$(MAKE) -f CMakeFiles/runTests.dir/build.make CMakeFiles/runTests.dir/test_funcs.cpp.o
.PHONY : test_funcs.cpp.o
test_funcs.i: test_funcs.cpp.i
.PHONY : test_funcs.i
# target to preprocess a source file
test_funcs.cpp.i:
$(MAKE) -f CMakeFiles/runTests.dir/build.make CMakeFiles/runTests.dir/test_funcs.cpp.i
.PHONY : test_funcs.cpp.i
test_funcs.s: test_funcs.cpp.s
.PHONY : test_funcs.s
# target to generate assembly for a file
test_funcs.cpp.s:
$(MAKE) -f CMakeFiles/runTests.dir/build.make CMakeFiles/runTests.dir/test_funcs.cpp.s
.PHONY : test_funcs.cpp.s
# Help Target
help:
@echo "The following are some of the valid targets for this Makefile:"
@echo "... all (the default if no target is provided)"
@echo "... clean"
@echo "... depend"
@echo "... rebuild_cache"
@echo "... runTests"
@echo "... edit_cache"
@echo "... test_funcs.o"
@echo "... test_funcs.i"
@echo "... test_funcs.s"
.PHONY : help
#=============================================================================
# Special targets to cleanup operation of make.
# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment