
#NOTE : Keep the same structure, commands must start on newline with VG_ as the begining of the var name
#as it is parsed later and used. And log names must start vg_ 

# You must set the VG_LOG_DIR before sourcing this file, If you alter the VG_LOG_DIR you must 
# resource this file
if [ -z "$VG_LOG_DIR" ]
then
    VG_LOG_DIR=.
    export VG_LOG_DIR
fi

VALGRIND_OPTIONS_QUOTED="\"--num-callers=50\" \"--leak-check=full\" \"--show-reachable=yes\" \"--show-possibly-lost=no\" \"--leak-resolution=high\" \"--tool=memcheck\" \"-v\" \"--gen-suppressions=all\" \"--suppressions=$OSPL_HOME/etc/valgrind-suppressions.txt\""

# We need to ignore shared memory - see OSPL-1626.  At present we only run valgrind on the examples and only on
# 32 bit linux, so we don't need to put anything complicated in at this stage to cater for different platforms.
# The contents of this file are copied verbatim into the release.com file so the following lines will be in the
# release.com and will result in the variables being set correctly when running the examples in shm mode
if [ "$EXRUNTYPE" = "shm" ]
then
   VALGRIND_OPTIONS_QUOTED="$VALGRIND_OPTIONS_QUOTED \"--ignore-ranges=0x20000000-0x20a00000\""
fi

# for VALGRIND_OPTIONS remove the \"
VALGRIND_OPTIONS=`echo $VALGRIND_OPTIONS_QUOTED | sed 's@\"@@g'`

#Used in the example runs
VG_PONG="valgrind --log-file=$VG_LOG_DIR/vg_pong.txt $VALGRIND_OPTIONS"
VG_PING_M="valgrind --log-file=$VG_LOG_DIR/vg_ping_m.txt $VALGRIND_OPTIONS"
VG_PING_Q="valgrind --log-file=$VG_LOG_DIR/vg_ping_q.txt $VALGRIND_OPTIONS"
VG_PING_S="valgrind --log-file=$VG_LOG_DIR/vg_ping_s.txt $VALGRIND_OPTIONS"
VG_PING_B="valgrind --log-file=$VG_LOG_DIR/vg_ping_b.txt $VALGRIND_OPTIONS"
VG_PING_F="valgrind --log-file=$VG_LOG_DIR/vg_ping_f.txt $VALGRIND_OPTIONS"
VG_PING_T="valgrind --log-file=$VG_LOG_DIR/vg_ping_t.txt $VALGRIND_OPTIONS"
VG_MESSAGEBOARD="valgrind --log-file=$VG_LOG_DIR/vg_messageboard.txt $VALGRIND_OPTIONS"
VG_USERLOAD="valgrind --log-file=$VG_LOG_DIR/vg_userload.txt $VALGRIND_OPTIONS"
VG_CHATTER="valgrind --log-file=$VG_LOG_DIR/vg_chatter.txt $VALGRIND_OPTIONS"
VG_CHATTER_T="valgrind --log-file=$VG_LOG_DIR/vg_chatter_t.txt $VALGRIND_OPTIONS"
VG_OSPL_START="valgrind --log-file=$VG_LOG_DIR/vg_ospl_start.txt $VALGRIND_OPTIONS"
VG_OSPL_STOP="valgrind --log-file=$VG_LOG_DIR/vg_ospl_stop.txt $VALGRIND_OPTIONS"

VG_WHITELIST_EDITOR="valgrind --log-file=$VG_LOG_DIR/vg_whitelisteditor.txt --trace-children=yes $VALGRIND_OPTIONS"
VG_WHITELIST_VIEWER="valgrind --log-file=$VG_LOG_DIR/vg_whitelistviewer.txt --trace-children=yes $VALGRIND_OPTIONS"
VG_WHITELIST_MESSAGEBOARD="valgrind --log-file=$VG_LOG_DIR/vg_whitelistmessageboard.txt --trace-children=yes $VALGRIND_OPTIONS"


#Used after an ospl start as valgrind slows spliced 
#and other service startup by a considerable amount
VG_START_SLEEP="sleep 10"

#Used in code at time of fork/exec
#each of the valgrind args MUST be 'slashed double quoted' as this is the way the os_procCreate will use it
VG_SPLICED="valgrind \"--log-file=$VG_LOG_DIR/vg_spliced.txt\" $VALGRIND_OPTIONS_QUOTED"
VG_DURABILITY="valgrind \"--log-file=$VG_LOG_DIR/vg_durability.txt\" $VALGRIND_OPTIONS_QUOTED"
VG_NETWORKING="valgrind \"--log-file=$VG_LOG_DIR/vg_networking.txt\" $VALGRIND_OPTIONS_QUOTED"
VG_DDSI="valgrind \"--log-file=$VG_LOG_DIR/vg_ddsi.txt\" $VALGRIND_OPTIONS_QUOTED"
VG_SNETWORKING="valgrind \"--log-file=$VG_LOG_DIR/vg_snetworking.txt\" $VALGRIND_OPTIONS_QUOTED"
VG_CMSOAP="valgrind \"--log-file=$VG_LOG_DIR/vg_cmsoap.txt\" $VALGRIND_OPTIONS_QUOTED"

export VG_OSPL_START \
       VG_PONG \
       VG_PING_M \
       VG_PING_Q \
       VG_PING_S \
       VG_PING_B \
       VG_PING_F \
       VG_PING_T \
       VG_MESSAGEBOARD \
       VG_USERLOAD \
       VG_CHATTER \
       VG_CHATTER_T \
       VG_WHITELIST_EDITOR \
       VG_WHITELIST_VIEWER \
       VG_WHITELIST_MESSAGEBOARD \
       VG_OSPL_STOP \
       VG_SPLICED \
       VG_DURABILITY \
       VG_NETWORKING \
       VG_DDSI \
       VG_SNETWORKING \
       VG_CMSOAP \
       VG_START_SLEEP
