Unverified Commit 22c88b80 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #2182 from akohlmey/test-updates

Test program updates and related changes
parents f35d517a fdf72820
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -257,9 +257,9 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
  endif()
endif()

set(ENABLE_SANITIZER "none" CACHE STRING "Select a code sanitizer option (none (default), address, thread, undefined)")
set(ENABLE_SANITIZER "none" CACHE STRING "Select a code sanitizer option (none (default), address, leak, thread, undefined)")
mark_as_advanced(ENABLE_SANITIZER)
set(ENABLE_SANITIZER_VALUES none address thread undefined)
set(ENABLE_SANITIZER_VALUES none address leak thread undefined)
set_property(CACHE ENABLE_SANITIZER PROPERTY STRINGS ${ENABLE_SANITIZER_VALUES})
validate_option(ENABLE_SANITIZER ENABLE_SANITIZER_VALUES)
string(TOLOWER ${ENABLE_SANITIZER} ENABLE_SANITIZER)
+15 −0
Original line number Diff line number Diff line
@@ -3,6 +3,21 @@
###############################################################################
option(ENABLE_TESTING "Enable testing" OFF)
if(ENABLE_TESTING)
  find_program(VALGRIND_BINARY NAMES valgrind)
  # generate custom suppression file
  file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/lammps.supp "\n")
  file(GLOB VALGRIND_SUPPRESSION_FILES ${LAMMPS_TOOLS_DIR}/valgrind/[^.]*.supp)
  foreach(SUPP ${VALGRIND_SUPPRESSION_FILES})
    file(READ ${SUPP} SUPPRESSIONS)
    file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/lammps.supp "${SUPPRESSIONS}")
  endforeach()
  set(VALGRIND_DEFAULT_OPTIONS "--leak-check=full --show-leak-kinds=all --track-origins=yes --suppressions=${CMAKE_BINARY_DIR}/lammps.supp")

  set(MEMORYCHECK_COMMAND "${VALGRIND_BINARY}" CACHE FILEPATH "Memory Check Command")
  set(MEMORYCHECK_COMMAND_OPTIONS "${VALGRIND_DEFAULT_OPTIONS}" CACHE STRING "Memory Check Command Options")

  include(CTest)

  enable_testing()
  get_filename_component(LAMMPS_UNITTEST_DIR ${LAMMPS_SOURCE_DIR}/../unittest ABSOLUTE)
  get_filename_component(LAMMPS_UNITTEST_BIN ${CMAKE_BINARY_DIR}/unittest ABSOLUTE)
+3 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ compilation and linking stages. This is done through setting the

   -D ENABLE_SANITIZER=none       # no sanitizer active (default)
   -D ENABLE_SANITIZER=address    # enable address sanitizer / memory leak checker
   -D ENABLE_SANITIZER=leak       # enable memory leak checker (only)
   -D ENABLE_SANITIZER=undefined  # enable undefined behavior sanitizer
   -D ENABLE_SANITIZER=thread     # enable thread sanitizer

@@ -121,6 +122,8 @@ The ``ctest`` command has many options, the most important ones are:
     - exclude subset of tests matching the regular expression <regex>
   * - -N
     - dry-run: display list of tests without running them
   * - -T memcheck
     - run tests with valgrind memory checker (if available)

In its full implementation, the unit test framework will consist of multiple
kinds of tests implemented in different programming languages (C++, C, Python,
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ using namespace MathConst;
Angle::Angle(LAMMPS *lmp) : Pointers(lmp)
{
  energy = 0.0;
  virial[0] = virial[1] = virial[2] = virial[3] = virial[4] = virial[5] = 0.0;
  writedata = 1;

  allocated = 0;
+15 −0
Original line number Diff line number Diff line
@@ -33,6 +33,9 @@ AngleHybrid::AngleHybrid(LAMMPS *lmp) : Angle(lmp)
{
  writedata = 0;
  nstyles = 0;
  nanglelist = nullptr;
  maxangle = nullptr;
  anglelist = nullptr;
}

/* ---------------------------------------------------------------------- */
@@ -105,6 +108,18 @@ void AngleHybrid::compute(int eflag, int vflag)

  ev_init(eflag,vflag);

  // need to clear per-thread storage here, when using multiple threads
  // with thread-enabled substyles to avoid uninitlialized data access.

  const int nthreads = comm->nthreads;
  if (comm->nthreads > 1) {
    const int nall = atom->nlocal + atom->nghost;
    if (eflag_atom)
      memset(&eatom[0],0,nall*nthreads*sizeof(double));
    if (vflag_atom)
      memset(&vatom[0][0],0,6*nall*nthreads*sizeof(double));
  }

  for (m = 0; m < nstyles; m++) {
    neighbor->nanglelist = nanglelist[m];
    neighbor->anglelist = anglelist[m];
Loading