<commit_before>#!/bin/bash

ulimit -s 8192
set -e # fail on any error

HERE=$(dirname $0)
TSAN_DIR=$(dirname $0)/../../lib/tsan
BLACKLIST=$HERE/Helpers/blacklist.txt

# Assume clang and clang++ are in path.
: ${CC:=clang}
: ${CXX:=clang++}
: ${FILECHECK:=FileCheck}

# TODO: add testing for all of -O0...-O3
CFLAGS="-fsanitize=thread -fsanitize-blacklist=$BLACKLIST -fPIE -O1 -g -Wall"
LDFLAGS="-pie -pthread -ldl -lrt -lm -Wl,--whole-archive $TSAN_DIR/rtl/libtsan.a -Wl,--no-whole-archive"

test_file() {
  SRC=$1
  COMPILER=$2
  echo ----- TESTING $(basename $1)
  OBJ=$SRC.o
  EXE=$SRC.exe
  $COMPILER $SRC $CFLAGS -c -o $OBJ
  $COMPILER $OBJ $LDFLAGS -o $EXE
  RES=$($EXE 2>&1 || true)
  printf "%s\n" "$RES" | $FILECHECK $SRC
  if [ "$3" == "" ]; then
    rm -f $EXE $OBJ
  fi
}

if [ "$1" == "" ]; then
  for c in $HERE/*.{c,cc}; do
    if [[ $c == */failing_* ]]; then
      echo SKIPPING FAILING TEST $c
      continue
    fi
    if [[ $c == */load_shared_lib.cc ]]; then
      echo TEST $c is not supported
      continue
    fi
    if [ "`grep "TSAN_OPTIONS" $c`" ]; then
      echo SKIPPING $c -- requires TSAN_OPTIONS
      continue
    fi
    COMPILER=$CXX
    case $c in
      *.c) COMPILER=$CC
    esac
    test_file $c $COMPILER &
  done<commit_msg>[TSan] Exclude blacklist tests from manual test runner<commit_after>#!/bin/bash

ulimit -s 8192
set -e # fail on any error

HERE=$(dirname $0)
TSAN_DIR=$(dirname $0)/../../lib/tsan

# Assume clang and clang++ are in path.
: ${CC:=clang}
: ${CXX:=clang++}
: ${FILECHECK:=FileCheck}

# TODO: add testing for all of -O0...-O3
CFLAGS="-fsanitize=thread -fPIE -O1 -g -Wall"
LDFLAGS="-pie -pthread -ldl -lrt -lm -Wl,--whole-archive $TSAN_DIR/rtl/libtsan.a -Wl,--no-whole-archive"

test_file() {
  SRC=$1
  COMPILER=$2
  echo ----- TESTING $(basename $1)
  OBJ=$SRC.o
  EXE=$SRC.exe
  $COMPILER $SRC $CFLAGS -c -o $OBJ
  $COMPILER $OBJ $LDFLAGS -o $EXE
  RES=$($EXE 2>&1 || true)
  printf "%s\n" "$RES" | $FILECHECK $SRC
  if [ "$3" == "" ]; then
    rm -f $EXE $OBJ
  fi
}

if [ "$1" == "" ]; then
  for c in $HERE/*.{c,cc}; do
    if [[ $c == */failing_* ]]; then
      echo SKIPPING FAILING TEST $c
      continue
    fi
    if [[ $c == */load_shared_lib.cc ]]; then
      echo TEST $c is not supported
      continue
    fi
    if [[ $c == */*blacklist*.cc ]]; then
      echo TEST $c is not supported
      continue
    fi
    if [ "`grep "TSAN_OPTIONS" $c`" ]; then
      echo SKIPPING $c -- requires TSAN_OPTIONS
      continue
    fi
    COMPILER=$CXX
    case $c in
      *.c) COMPILER=$CC
    esac
    test_file $c $COMPILER &
  done
{'fraction_non_alphanumeric': 0.18108419838523646, 'fraction_numerical': 0.012302960399846213, 'mean_word_length': 2.5546448087431695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5491544', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1045, 'n_words': 288}