Skip to content

Commit

Permalink
Debugging SEGFAULT in expression unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
krivenko committed Jan 24, 2024
1 parent 5622fbc commit 2ab5d01
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 85 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/build-test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- ci
- debug
pull_request:
branches:
- master
Expand All @@ -13,9 +14,8 @@ jobs:
build-test-deploy:
strategy:
matrix:
os: [ubuntu-20.04, macos-11]
os: [macos-12]
cxx_compiler:
- { name: "gcc", cxx: "g++-10" }
- { name: "clang", cxx: "clang++" }
runs-on: ${{ matrix.os }}

Expand All @@ -32,21 +32,21 @@ jobs:
brew install eigen
fi
- name: Set up Python 3.8
if: startsWith(matrix.cxx_compiler.name, 'clang')
uses: actions/setup-python@v4
with:
python-version: 3.8
#- name: Set up Python 3.8
# if: startsWith(matrix.cxx_compiler.name, 'clang')
# uses: actions/setup-python@v4
# with:
# python-version: 3.8

- name: Install cppcheck
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get install cppcheck
#- name: Install cppcheck
# if: startsWith(matrix.os, 'ubuntu')
# run: sudo apt-get install cppcheck

- name: Install Sphinx and Read the Docs Sphinx Theme
if: startsWith(matrix.cxx_compiler.name, 'clang')
run: |
python -m pip install --upgrade pip
pip install sphinx sphinx-rtd-theme myst-parser
#- name: Install Sphinx and Read the Docs Sphinx Theme
# if: startsWith(matrix.cxx_compiler.name, 'clang')
# run: |
# python -m pip install --upgrade pip
# pip install sphinx sphinx-rtd-theme myst-parser

- name: Build libcommute
run: |
Expand All @@ -64,18 +64,18 @@ jobs:
DOCS=OFF
fi
CXX="${{ matrix.cxx_compiler.cxx }}" cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/installed \
-DSTATIC_ANALYSIS=${STATIC_ANALYSIS} \
-DTESTS=ON \
-DEXAMPLES=ON \
-DDOCUMENTATION=${DOCS}
-DEXAMPLES=OFF \
-DDOCUMENTATION=OFF
make -j3
- name: Test libcommute
run: |
cd ${GITHUB_WORKSPACE}/build
CTEST_OUTPUT_ON_FAILURE=1 make test
ctest --debug
- name: Install libcommute
run: |
cd ${GITHUB_WORKSPACE}/build
Expand Down
5 changes: 3 additions & 2 deletions include/libcommute/expression/expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <complex>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <tuple>
Expand Down Expand Up @@ -947,7 +948,7 @@ class expression<ScalarType, IndexTypes...>::const_iterator {

// Increments
const_iterator& operator++() {
++m_it_;
std::advance(m_it_, 1);
return *this;
}
const_iterator operator++(int) {
Expand All @@ -958,7 +959,7 @@ class expression<ScalarType, IndexTypes...>::const_iterator {

// Decrements
const_iterator& operator--() {
--m_it_;
std::advance(m_it_, -1);
return *this;
}
const_iterator operator--(int) {
Expand Down
128 changes: 64 additions & 64 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,38 @@ endif(STATIC_ANALYSIS)
include_directories(BEFORE SYSTEM catch2)

set(TESTS
utility
metafunctions
generator
monomial
scalar_traits
factories
#utility
#metafunctions
#generator
#monomial
#scalar_traits
#factories
expression
expression.addition
expression.subtraction
expression.multiplication
expression.const.addition
expression.const.subtraction
expression.const.multiplication
expression.mixed_arithmetics
hc
commutators
new_algebra
state_vector
elementary_space
hilbert_space
monomial_action
monomial_action_fermion
monomial_action_boson
monomial_action_spin
loperator
new_algebra.loperator
disjoint_sets
sparse_state_vector
space_partition
mapped_basis_view
n_fermion_sector_view
n_fermion_multisector_view
#expression.addition
#expression.subtraction
#expression.multiplication
#expression.const.addition
#expression.const.subtraction
#expression.const.multiplication
#expression.mixed_arithmetics
#hc
#commutators
#new_algebra
#state_vector
#elementary_space
#hilbert_space
#monomial_action
#monomial_action_fermion
#monomial_action_boson
#monomial_action_spin
#loperator
#new_algebra.loperator
#disjoint_sets
#sparse_state_vector
#space_partition
#mapped_basis_view
#n_fermion_sector_view
#n_fermion_multisector_view
)

# Build C++ unit tests
Expand All @@ -62,36 +62,36 @@ foreach(t ${TESTS})
add_test(NAME ${t} COMMAND ${t})
endforeach()

set(CXX17_TESTS
dyn_indices
generator_dyn
factories_dyn
elementary_space_dyn
)

# C++17 tests
if("cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
message(STATUS "Enabling C++17 tests")
foreach(t ${CXX17_TESTS})
set(s ${CMAKE_CURRENT_SOURCE_DIR}/${t}.cpp)
add_executable(${t} ${s})
target_compile_features(${t} PRIVATE cxx_std_17)
target_link_libraries(${t} PRIVATE libcommute catch2)
add_test(NAME ${t} COMMAND ${t})
endforeach()
else()
message(STATUS "Disabling C++17 tests")
endif()

# Tests using Eigen 3
if(Eigen3_FOUND)
message(STATUS "Enabling Eigen 3 tests")
set(EIGEN3_TESTS state_vector_eigen3)
foreach(t ${EIGEN3_TESTS})
set(s ${CMAKE_CURRENT_SOURCE_DIR}/${t}.cpp)
add_executable(${t} ${s})
target_link_libraries(${t} PRIVATE libcommute catch2)
link_to_eigen3(${t})
add_test(NAME ${t} COMMAND ${t})
endforeach()
endif(Eigen3_FOUND)
#set(CXX17_TESTS
# dyn_indices
# generator_dyn
# factories_dyn
# elementary_space_dyn
#)
#
## C++17 tests
#if("cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
# message(STATUS "Enabling C++17 tests")
# foreach(t ${CXX17_TESTS})
# set(s ${CMAKE_CURRENT_SOURCE_DIR}/${t}.cpp)
# add_executable(${t} ${s})
# target_compile_features(${t} PRIVATE cxx_std_17)
# target_link_libraries(${t} PRIVATE libcommute catch2)
# add_test(NAME ${t} COMMAND ${t})
# endforeach()
#else()
# message(STATUS "Disabling C++17 tests")
#endif()
#
## Tests using Eigen 3
#if(Eigen3_FOUND)
# message(STATUS "Enabling Eigen 3 tests")
# set(EIGEN3_TESTS state_vector_eigen3)
# foreach(t ${EIGEN3_TESTS})
# set(s ${CMAKE_CURRENT_SOURCE_DIR}/${t}.cpp)
# add_executable(${t} ${s})
# target_link_libraries(${t} PRIVATE libcommute catch2)
# link_to_eigen3(${t})
# add_test(NAME ${t} COMMAND ${t})
# endforeach()
#endif(Eigen3_FOUND)

0 comments on commit 2ab5d01

Please sign in to comment.