Skip to content

Commit

Permalink
Merge branch 'release/0.2.2'
Browse files Browse the repository at this point in the history
* release/0.2.2: (61 commits)
  Fix hakabana path in workshop
  Bump patch version
  Use simpler error check
  Add support for 802.1q in pcap capture module
  Fix regex match
  Fix lua stack leak
  Update test results
  Fix test issue on release
  Add function to share logging code
  Update test results
  Fix test update script
  Fix state machine Lua ref issue
  Fix Lua weak ref
  Fix compilation on 32 bit system
  Improve memory info
  Update test results
  Add debug log for connection release
  Remove state machine finish on destroy
  Fix lua ref for negative index
  Add weak lua ref
  ...
  • Loading branch information
paulfariello committed Nov 19, 2014
2 parents 8c27453 + e0aaad0 commit fd739fa
Show file tree
Hide file tree
Showing 159 changed files with 1,018 additions and 380 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ add_custom_target(localinstall
COMMAND $(MAKE) install DESTDIR=${LOCALINSTALL}
COMMAND echo "export LD_LIBRARY_PATH=\"${LOCALINSTALL}${CMAKE_INSTALL_PREFIX}/lib:${LOCALINSTALL}${CMAKE_INSTALL_PREFIX}/lib/haka:${LOCALINSTALL}${CMAKE_INSTALL_PREFIX}/lib/haka/modules/protocol:${LOCALINSTALL}${CMAKE_INSTALL_PREFIX}/lib/haka/modules/packet:${LOCALINSTALL}${CMAKE_INSTALL_PREFIX}/lib/haka/modules/misc\"" > ${ENV_SH}
COMMAND echo "export HAKA_PATH=\"${LOCALINSTALL}${CMAKE_INSTALL_PREFIX}\"" >> ${ENV_SH}
COMMAND echo "export PATH=\"${LOCALINSTALL}${CMAKE_INSTALL_PREFIX}/bin\":\"${LOCALINSTALL}${CMAKE_INSTALL_PREFIX}/sbin\":$PATH" >> ${ENV_SH}
COMMAND echo "export PATH=\"${LOCALINSTALL}${CMAKE_INSTALL_PREFIX}/bin\":\"${LOCALINSTALL}${CMAKE_INSTALL_PREFIX}/sbin\":\"${LOCALINSTALL}${CMAKE_INSTALL_PREFIX}/share/haka/scripts/\":$PATH" >> ${ENV_SH}
COMMAND echo "export LUA_PATH=\"\$(realpath \$HAKA_PATH/share/haka/lua/share/luajit* | head -n 1)/?.lua\"" >> ${ENV_SH}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Install locally..." VERBATIM
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Dependencies
* rsync
* libpcap
* gawk
* libeditline
* libedit
* libpcre

### Optional
Expand Down
13 changes: 13 additions & 0 deletions build/CompareOutput.awk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ BEGIN {
show = 0
trace = 0
alert = 0
closing = 0
}

$0 ~ /^[^ \t]+[ \t]+[^:]+:[ ]+.*$/ {
Expand Down Expand Up @@ -39,6 +40,7 @@ $0 ~ /^debug state-machine:/ { next; }
$0 ~ /^debug event: signal/ { next; }
$0 ~ /^debug timer: / { next; }
$0 ~ /^info pcap: progress/ { next; }
$0 ~ /^debug core: memory report/ { next; }

$0 ~ /^debug grammar: in rule / {
trace = 1;
Expand Down Expand Up @@ -67,6 +69,17 @@ $0 ~ /^\ttime = / {
next;
}

$0 ~ /^debug lua: closing state$/ {
closing = 1;
}

$0 ~ /^debug cnx: .* connection/ {
if (closing) {
print($1 " " $2 " <cleanup> " $4);
next;
}
}

{
if (show == 2 && trace == 0) {
print;
Expand Down
4 changes: 4 additions & 0 deletions build/ComparePcap.awk
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ $0 ~ /^[ ]+\[Response time: .*\]$/ {
next;
}

$0 ~ /.*\[iRTT: / {
next;
}

{
print;
}
Expand Down
10 changes: 9 additions & 1 deletion build/ComparePcap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@
TSHARK_ARGS="-o ip.check_checksum:TRUE -o udp.check_checksum:TRUE -o tcp.check_checksum:TRUE"

$TSHARK $TSHARK_ARGS -Vr $1 | gawk -f $BUILD_DIR/ComparePcap.awk - > $(basename $1).txt
if [ $? != 0 ]; then
echo "Pcap compare failed"
exit 1
fi

$TSHARK $TSHARK_ARGS -Vr $2 | gawk -f $BUILD_DIR/ComparePcap.awk - > $(basename $2).txt
if [ $? != 0 ]; then
echo "Pcap compare failed"
exit 1
fi

$DIFF -u $(basename $1).txt $(basename $2).txt > $(basename $1).diff
RET=$?

cat $(basename $1).diff
exit $RET

7 changes: 3 additions & 4 deletions build/FindCheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ include(FindPackageHandleStandardArgs)

find_path(CHECK_INCLUDE_DIRS NAMES check.h)
find_library(CHECK_LIBRARIES NAMES check)
if(CHECK_LIBRARIES)
set(CHECK_FOUND)
endif(CHECK_LIBRARIES)
find_package(Threads REQUIRED)

list(APPEND CHECK_LIBRARIES rt)
list(APPEND CHECK_LIBRARIES m)
list(APPEND CHECK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})

FIND_PACKAGE_HANDLE_STANDARD_ARGS(CHECK
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Check
REQUIRED_VARS CHECK_LIBRARIES CHECK_INCLUDE_DIRS)
6 changes: 1 addition & 5 deletions build/FindEditline.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
find_path(EDITLINE_INCLUDE_DIR editline/readline.h)
find_library(EDITLINE_LIBRARY NAMES edit)

if(EDITLINE_INCLUDE_DIR AND EDITLINE_LIBRARY)
set(EDITLINE_FOUND)
endif()

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(EDITLINE
find_package_handle_standard_args(Editline
REQUIRED_VARS EDITLINE_LIBRARY EDITLINE_INCLUDE_DIR)
11 changes: 11 additions & 0 deletions build/FindIniparser.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

find_path(INIPARSER_INCLUDE_DIR iniparser.h)
find_library(INIPARSER_LIBRARY iniparser)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(Iniparser
REQUIRED_VARS INIPARSER_LIBRARY INIPARSER_INCLUDE_DIR)
4 changes: 0 additions & 4 deletions build/FindJansson.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
find_path(JANSSON_INCLUDE_DIR jansson.h)
find_library(JANSSON_LIBRARY NAMES jansson)

if(JANSSON_INCLUDE_DIR AND JANSSON_LIBRARY)
set(JANSSON_FOUND)
endif()

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(Jansson
Expand Down
4 changes: 0 additions & 4 deletions build/FindLCov.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@ find_program(LCOV_EXECUTABLE NAMES lcov
DOC "Lcov coverage tool"
)

if(LCOV_EXECUTABLE)
set(LCOV_FOUND)
endif(LCOV_EXECUTABLE)

find_package_handle_standard_args(LCov REQUIRED_VARS LCOV_EXECUTABLE)
4 changes: 0 additions & 4 deletions build/FindLibCurl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
find_path(LIBCURL_INCLUDE_DIR curl/curl.h)
find_library(LIBCURL_LIBRARY NAMES curl)

if(LIBCURL_INCLUDE_DIR AND LIBCURL_LIBRARY)
set(LIBCURL_FOUND)
endif()

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(LibCurl
Expand Down
4 changes: 0 additions & 4 deletions build/FindLibGeoIP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
find_path(LIBGEOIP_INCLUDE_DIR GeoIP.h)
find_library(LIBGEOIP_LIBRARY NAMES GeoIP)

if(LIBGEOIP_INCLUDE_DIR AND LIBGEOIP_LIBRARY)
set(LIBGEOIP_FOUND)
endif()

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(LibGeoIP
Expand Down
4 changes: 0 additions & 4 deletions build/FindLibUuid.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
find_path(LIBUUID_INCLUDE_DIR uuid/uuid.h)
find_library(LIBUUID_LIBRARY NAMES uuid)

if(LIBUUID_INCLUDE_DIR AND LIBUUID_LIBRARY)
set(LIBUUID_FOUND)
endif()

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(LibUuid
Expand Down
2 changes: 1 addition & 1 deletion build/FindNetfilterQueue.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ include(FindPackageHandleStandardArgs)
find_path(NETFILTERQUEUE_INCLUDE_DIR NAMES libnetfilter_queue/libnetfilter_queue.h)
find_library(NETFILTERQUEUE_LIBRARIES NAMES netfilter_queue)

find_package_handle_standard_args(NETFILTERQUEUE
find_package_handle_standard_args(NetFilterQueue
REQUIRED_VARS NETFILTERQUEUE_LIBRARIES NETFILTERQUEUE_INCLUDE_DIR)
11 changes: 11 additions & 0 deletions build/FindRsync.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

include(FindPackageHandleStandardArgs)

find_program(RSYNC_EXECUTABLE NAMES rsync
DOC "Rsync file-copying tool"
)

find_package_handle_standard_args(Rsync REQUIRED_VARS RSYNC_EXECUTABLE)
6 changes: 3 additions & 3 deletions build/TestBenchRun.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ set(ENV{LANG} "C")
set(ENV{LC_ALL} "C")
set(ENV{BUILD_DIR} ${CTEST_MODULE_DIR})
set(ENV{LUA_PATH} ${PROJECT_SOURCE_DIR}/src/lua/?.lua)
set(ENV{HAKA} ${HAKA})
set(ENV{HAKA_PATH} ${HAKA_PATH})
set(ENV{PATH} $ENV{PATH}:${HAKA_PATH}/sbin:${HAKA_PATH}/bin)
set(ENV{LD_LIBRARY_PATH} ${HAKA_PATH}/lib:${HAKA_PATH}/lib/haka/modules/protocol:${HAKA_PATH}/lib/haka/modules/packet)
set(ENV{TZ} Europe/Paris)
set(ENV{CONF} ${CONF})

set(CMAKE_MODULE_PATH ${CTEST_MODULE_DIR} ${CMAKE_MODULE_PATH})

message("Executing TZ=\"Europe/Paris\" LANG=\"C\" LC_ALL=\"C\" LUA_PATH=\"$ENV{LUA_PATH}\" HAKA_PATH=\"$ENV{HAKA_PATH}\" LD_LIBRARY_PATH=\"$ENV{LD_LIBRARY_PATH}\" CONF=\"$ENV{CONF}\" ${EXE} ${BENCH}")
message("Executing TZ=\"Europe/Paris\" LANG=\"C\" LC_ALL=\"C\" LUA_PATH=\"$ENV{LUA_PATH}\" HAKA=\"$ENV{HAKA}\" HAKA_PATH=\"$ENV{HAKA_PATH}\" LD_LIBRARY_PATH=\"$ENV{LD_LIBRARY_PATH}\" ${EXE} ${EXE_OPTIONS} ${BENCH}")

execute_process(COMMAND ${EXE} ${BENCH} RESULT_VARIABLE HAD_ERROR)
execute_process(COMMAND ${EXE} ${EXE_OPTIONS} ${BENCH} RESULT_VARIABLE HAD_ERROR)

if(HAD_ERROR)
message(FATAL_ERROR "Benchmark script failed")
Expand Down
52 changes: 29 additions & 23 deletions build/TestUnit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,34 @@
# This test will run a Check unit test program build from the sources
# TEST_UNIT_FILES given as argument.

find_package(Check REQUIRED)
find_package(Check)

macro(TEST_UNIT)
set(oneValueArgs MODULE NAME)
set(multiValueArgs FILES ENV)
cmake_parse_arguments(TEST_UNIT "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(CHECK_FOUND)
macro(TEST_UNIT)
set(oneValueArgs MODULE NAME)
set(multiValueArgs FILES ENV LIBS)
cmake_parse_arguments(TEST_UNIT "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

add_executable(${TEST_UNIT_MODULE}-${TEST_UNIT_NAME} ${TEST_UNIT_FILES})
target_link_libraries(${TEST_UNIT_MODULE}-${TEST_UNIT_NAME} ${CHECK_LIBRARIES})
set_property(TARGET ${TEST_UNIT_MODULE}-${TEST_UNIT_NAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${CHECK_INCLUDE_DIRS})
set_property(TARGET ${TEST_UNIT_MODULE}-${TEST_UNIT_NAME} APPEND PROPERTY LINK_FLAGS -Wl,--exclude-libs,ALL)
add_test(NAME ${TEST_UNIT_MODULE}-${TEST_UNIT_NAME}-unit
COMMAND ${CMAKE_COMMAND}
-DCTEST_MODULE_DIR=${CTEST_MODULE_DIR}
-DPROJECT_SOURCE_DIR=${CMAKE_SOURCE_DIR}
-DEXE=${CMAKE_CURRENT_BINARY_DIR}/${TEST_UNIT_MODULE}-${TEST_UNIT_NAME}
-DHAKA_PATH=${TEST_RUNDIR}
-DSRC=${CTEST_MODULE_DIR}/empty.pcap
-DDST=${TEST_UNIT_NAME}-out
-DDIFF=${DIFF_COMMAND}
-P ${CTEST_MODULE_DIR}/TestUnitRun.cmake)
list(APPEND TEST_UNIT_ENV "LD_LIBRARY_PATH=${LUA_LIBRARY_DIR}")
list(APPEND TEST_UNIT_ENV "HAKA_PATH=${TEST_RUNDIR}")
set_tests_properties(${TEST_UNIT_MODULE}-${TEST_UNIT_NAME}-unit PROPERTIES ENVIRONMENT "${TEST_UNIT_ENV}")
endmacro(TEST_UNIT)
add_executable(${TEST_UNIT_MODULE}-${TEST_UNIT_NAME} ${TEST_UNIT_FILES})
target_link_libraries(${TEST_UNIT_MODULE}-${TEST_UNIT_NAME} ${CHECK_LIBRARIES})
target_link_libraries(${TEST_UNIT_MODULE}-${TEST_UNIT_NAME} ${TEST_UNIT_LIBS})
set_property(TARGET ${TEST_UNIT_MODULE}-${TEST_UNIT_NAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${CHECK_INCLUDE_DIRS})
set_property(TARGET ${TEST_UNIT_MODULE}-${TEST_UNIT_NAME} APPEND PROPERTY LINK_FLAGS -Wl,--exclude-libs,ALL)
add_test(NAME ${TEST_UNIT_MODULE}-${TEST_UNIT_NAME}-unit
COMMAND ${CMAKE_COMMAND}
-DCTEST_MODULE_DIR=${CTEST_MODULE_DIR}
-DPROJECT_SOURCE_DIR=${CMAKE_SOURCE_DIR}
-DEXE=${CMAKE_CURRENT_BINARY_DIR}/${TEST_UNIT_MODULE}-${TEST_UNIT_NAME}
-DHAKA_PATH=${TEST_RUNDIR}
-DSRC=${CTEST_MODULE_DIR}/empty.pcap
-DDST=${TEST_UNIT_NAME}-out
-DDIFF=${DIFF_COMMAND}
-P ${CTEST_MODULE_DIR}/TestUnitRun.cmake)
list(APPEND TEST_UNIT_ENV "LD_LIBRARY_PATH=${LUA_LIBRARY_DIR}")
list(APPEND TEST_UNIT_ENV "HAKA_PATH=${TEST_RUNDIR}")
set_tests_properties(${TEST_UNIT_MODULE}-${TEST_UNIT_NAME}-unit PROPERTIES ENVIRONMENT "${TEST_UNIT_ENV}")
endmacro(TEST_UNIT)
else()
macro(TEST_UNIT)
endmacro(TEST_UNIT)
endif()
2 changes: 1 addition & 1 deletion build/TestUnitLuaRun.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

set(ENV{LANG} "C")
set(ENV{BUILD_DIR} ${CTEST_MODULE_DIR})
set(ENV{LUA_PATH} ${PROJECT_SOURCE_DIR}/src/lua/?.lua)
set(ENV{LUA_PATH} ${PROJECT_SOURCE_DIR}/external/luaunit/src/?.lua)
set(ENV{HAKA_PATH} ${HAKA_PATH})
set(ENV{LD_LIBRARY_PATH} ${HAKA_PATH}/lib)
set(ENV{TZ} Europe/Paris)
Expand Down
2 changes: 1 addition & 1 deletion build/UpdateTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

export HAKA_TEST_FIX=$(pwd)/haka-test-fix
export QUICK=yes
export VALGRIND=0

for i in $(seq $1 $2)
do
Expand Down
46 changes: 27 additions & 19 deletions build/UseLua.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ else()
message(FATAL_ERROR "Invalid Lua version")
endif()


set(LUAC "yes" CACHE BOOL "precompile lua files during build")


include_directories(${LUA_INCLUDE_DIR})

macro(LUA_COMPILE)
Expand All @@ -29,25 +33,29 @@ macro(LUA_COMPILE)

set(LUA_COMPILE_COMPILED_FILES)

foreach(it ${LUA_COMPILE_FILES})
get_filename_component(lua_source_file_path "${it}" ABSOLUTE)
get_filename_component(lua_source_file_name "${it}" NAME_WE)
set(lua_source_outfile_path "${lua_source_file_name}.bc")

add_custom_command(
OUTPUT "${lua_source_outfile_path}"
COMMAND ${LUA_COMPILER} ${LUA_FLAGS} -o ${lua_source_outfile_path} ${lua_source_file_path}
MAIN_DEPENDENCY "${lua_source_file_path}"
COMMENT "Building Lua file ${it}"
DEPENDS ${LUA_DEPENDENCY}
VERBATIM)

SET_SOURCE_FILES_PROPERTIES("${lua_source_outfile_path}" PROPERTIES GENERATED 1)
LIST(APPEND LUA_COMPILE_COMPILED_FILES "${CMAKE_CURRENT_BINARY_DIR}/${lua_source_outfile_path}")
endforeach(it)

get_directory_property(lua_extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${lua_extra_clean_files};${LUA_COMPILE_COMPILED_FILES}")
if(LUAC)
foreach(it ${LUA_COMPILE_FILES})
get_filename_component(lua_source_file_path "${it}" ABSOLUTE)
get_filename_component(lua_source_file_name "${it}" NAME_WE)
set(lua_source_outfile_path "${lua_source_file_name}.bc")

add_custom_command(
OUTPUT "${lua_source_outfile_path}"
COMMAND ${LUA_COMPILER} ${LUA_FLAGS} -o ${lua_source_outfile_path} ${lua_source_file_path}
MAIN_DEPENDENCY "${lua_source_file_path}"
COMMENT "Building Lua file ${it}"
DEPENDS ${LUA_DEPENDENCY}
VERBATIM)

SET_SOURCE_FILES_PROPERTIES("${lua_source_outfile_path}" PROPERTIES GENERATED 1)
LIST(APPEND LUA_COMPILE_COMPILED_FILES "${CMAKE_CURRENT_BINARY_DIR}/${lua_source_outfile_path}")
endforeach(it)

get_directory_property(lua_extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${lua_extra_clean_files};${LUA_COMPILE_COMPILED_FILES}")
else()
set(LUA_COMPILE_COMPILED_FILES ${LUA_COMPILE_FILES})
endif()

if(TARGET ${LUA_COMPILE_NAME})
get_target_property(ID ${LUA_COMPILE_NAME} LUA_ID)
Expand Down
37 changes: 37 additions & 0 deletions build/graphmem.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

cat > /tmp/gnuplot.script <<EOF
set term png small size 1200,800
set output "/tmp/mem-graph.png"
set ylabel "KB"
set ytics nomirror
set yrange [0:*]
set y2label "KB"
set y2tics nomirror in
set y2range [0:*]
plot "/tmp/mem.log" using 3 with lines axes x1y2 title "LUA", \
"/tmp/mem.log" using 1 with lines axes x1y1 title "VMSize", \
"/tmp/mem.log" using 2 with lines axes x1y1 title "RSSSize"
EOF

echo "0 0 0" > /tmp/mem.log
echo > /tmp/out.log

$* > /tmp/out.log &

gnuplot /tmp/gnuplot.script
eog /tmp/mem-graph.png &

while true; do
echo "0 0 0" > /tmp/mem.log
sed -n -e 's/^.*memory report:.*vmsize=\(.*\) rsssize=\(.*\) luasize=\(.*\)/\1 \2 \3/p' /tmp/out.log >> /tmp/mem.log
gnuplot /tmp/gnuplot.script

pidof $1 > /dev/null
if [ $? != 0 ]; then
break
fi

sleep 2
done
Loading

0 comments on commit fd739fa

Please sign in to comment.