Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test #37

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

name: CI ADAPTER

on:
push:
branches: main
pull_request:
branches: [ "main" ]


jobs:
Linux:
runs-on: ubuntu-latest
steps:
- name: using the Checkout action
uses: actions/checkout@v2
- name: Get latest CMake
uses: lukka/get-cmake@latest
- name: Install python packages
run: python -m pip install Jinja2 make pytest
- name: Install requirements for Verrou
run: sudo apt-get -qq update; sudo apt-get install -y libc-dbg
- name: Install requirements for building
run: sudo apt-get install -y build-essential g++ gcc autoconf automake
- name: Install requirements for verificarlo
run: sudo apt install clang lldb lld llvm opt libtool libmpfr-dev parallel
- name: Install Verificarlo
run: |
git clone https://github.com/verificarlo/verificarlo.git
cd verificarlo
./autogen.sh
./configure --without-flang
sudo make
sudo make install
- name: clone PENE
run: |
cd pene_files
git clone https://github.com/aneoconsulting/PENE.git
- name: runing cmake for Verificarlo and PENE tools (Linux)
run: |
mkdir build
cd build
cmake .. -DBUILD_FOR_PENE=ON -DBUILD_FOR_VERIFICARLO=ON
- name: Building (Linux)
run : |
cd build
cmake --build .
- name: Testing (Linux)
run : |
cd Test
mkdir build
cd build
cmake .. -DTEST_PENE=ON
make
ctest -C Debug --output-o-failure


13 changes: 13 additions & 0 deletions Test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

cmake_minimum_required(VERSION 3.12)

project(Tests_All_Frontend)


set(CMAKE_GENERICS_PATH "${CMAKE_SOURCE_DIR}")

enable_testing()

add_subdirectory("Test_result")
add_subdirectory("Test_counter")
add_subdirectory("Test_binary")
2 changes: 2 additions & 0 deletions Test/GenericConfigureFile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

configure_file(${INFILE} ${OUTFILE})
93 changes: 93 additions & 0 deletions Test/Test_binary/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@


cmake_minimum_required (VERSION 3.20)

project(Test_binary)

find_package(Python3 COMPONENTS Interpreter REQUIRED)

add_executable(test_verificarlo_bin executable.cpp)
add_executable(test_verrou_bin executable.cpp)

set_property(TARGET test_verrou_bin PROPERTY CXX_STANDARD 17)

set(PYTHON_SCRIPT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/test_binary.py)
get_filename_component(PARENT_DIR ${CMAKE_SOURCE_DIR} DIRECTORY)
get_filename_component(GRANDPARENT_DIR ${PARENT_DIR} DIRECTORY)
set(PIN_PATH ${PARENT_DIR}/pene_files/PENE/Pin/Linux/pin)
set(LIB_PATH ${PARENT_DIR}/pene_files/PENE/src/libpene.so)

# set(CMAKE_GENERICS_PATH "${CMAKE_SOURCE_DIR}")


set(new_back_verificarlo ${PARENT_DIR}/verificarlo_files/backends_so/libtarget_backend_test_1.so)

set(TOOL_PATH ${PARENT_DIR}/pene_files/PENE/cmake/tools)

add_custom_command(
#OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/verificarlo_exe
TARGET test_verificarlo_bin
PRE_BUILD
COMMAND verificarlo-c++ ${CMAKE_CURRENT_SOURCE_DIR}/executable.cpp -o ${CMAKE_CURRENT_BINARY_DIR}/verificarlo_exe
COMMENT "Building verificarlo_exe"
)


add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_binary.py
COMMAND ${CMAKE_COMMAND}
-D INFILE=${CMAKE_CURRENT_SOURCE_DIR}/test_binary.py
-D OUTFILE=${CMAKE_CURRENT_BINARY_DIR}/test_binary.py
-D REPLACE_TESTS_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}
-D VERIFICARLO_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/verificarlo_exe
-D BACKEND_VERIFICARLO=${new_back_verificarlo}
-D VERROU_EXECUTABLE=$<TARGET_FILE:test_verrou_bin>
-D LIB=${LIB_PATH}
-D PIN_EXECUTABLE=${PIN_PATH}
-P ${CMAKE_GENERICS_PATH}/GenericConfigureFile.cmake
DEPENDS
${CMAKE_GENERICS_PATH}/GenericConfigureFile.cmake
COMMENT "Configuring test_binary.py"
VERBATIM
)


set(TEST_SCRIPTS test_binary.py)

list(TRANSFORM TEST_SCRIPTS PREPEND ${CMAKE_CURRENT_BINARY_DIR}/)
add_custom_target(${PROJECT_NAME} ALL DEPENDS
${TEST_SCRIPTS}
${CMAKE_CURRENT_BINARY_DIR}/test_binary.py
)

enable_testing()


option(TEST_PENE "Enable testing for PENE" OFF)
option(TEST_VERIFICARLO "Enable testing for Verificarlo" OFF)

set(PENE_TESTS test_binary_PENE)
set(VERIFICARLO_TESTS test_binary_Verificarlo)

set(TEST_LIST)

if(TEST_PENE)
list(APPEND TEST_LIST ${PENE_TESTS})
endif()

if(TEST_VERIFICARLO)
list(APPEND TEST_LIST ${VERIFICARLO_TESTS})
endif()

if(NOT "${TEST_LIST}" STREQUAL "")
foreach(test ${TEST_LIST})
add_test(NAME ${test}
COMMAND ${Python3_EXECUTABLE} -m pytest -k ${test} ${CMAKE_CURRENT_BINARY_DIR}/test_binary.py
)
endforeach()
else()
message(WARNING "No tests specified. Please enable either TEST_PENE or TEST_VERIFICARLO to run specific tests.")
endif()


include_directories("../../pene_files/PENE/Pin/Linux")
include_directories("../../pene_files/PENE/src")
21 changes: 21 additions & 0 deletions Test/Test_binary/executable.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@


#include <immintrin.h>
#include <iostream>
#include <string>
#include <iomanip>

int main(){

std::cout<< "This programme is used for tests the instrumentation of the programme with the three tools" << std::endl;

float z = 1.0;
float x = 0.0;

float sum = z+x;

std::cout << "Result :" << std::endl;
std::cout << std::setprecision(23) << std::hexfloat << sum << std::endl;

return 0;
}
82 changes: 82 additions & 0 deletions Test/Test_binary/test_binary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@



import pytest
import re
import subprocess
from pathlib import Path
import sys
import os

class Test_front():

verificarlo = "@VERIFICARLO_EXECUTABLE@"
verrou = "@VERROU_EXECUTABLE@"
pin = "@PIN_EXECUTABLE@"
lib = "@LIB@"
new_back = "@BACKEND_VERIFICARLO@"

expected = r"0x1\.000002p\+0"

def launch_PENE(self):

cmdLine = ("{pin} -t {tool} -fp-replace 5 -counter_mode 1 -- {executable}").format(pin = self.pin,
tool = self.lib,
executable = self.verrou,
)


out = subprocess.run(cmdLine.split(" "), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

output = out.stdout.decode('utf-8')
print(output)

p = r"\A=*[\r\n]{1,2}\s*?PENE: Pin Enabled Numerical Exploration\s*?[\r\n]{1,2}=*[\r\n]{1,2}"
assert re.search(p, output) is not None, f"failed to launch instrumentation with PENE"

return output


def launch_verificarlo(self):

command = ("VFC_BACKENDS=\"{back} --count-op\" {verificarlo}").format(back=self.new_back,
verificarlo=self.verificarlo,
)

process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

output, error = process.communicate()

output_str = output.decode("utf-8")
print(output_str)

p = r"loaded backend"
assert re.search(p, output_str) is not None, f"failed to launch instrumentation with Verificarlo"

return output_str

def checkout_binary(self, pattern, expected):

p = re.compile(expected)

res = p.search(pattern)
assert res, "The result is false"


def test_binary_PENE(self):

output=self.launch_PENE()
self.checkout_binary(output, self.expected)

def test_binary_Verificarlo(self):

output=self.launch_verificarlo()
self.checkout_binary(output, self.expected)


if __name__ == "__main__":
pytest.main()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make the execution of a frontend depending on arguments and only giving PENE as parameter ?





93 changes: 93 additions & 0 deletions Test/Test_counter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a way to reduce redundancy of CMaksLists?

Copy link
Contributor Author

@MEKBAL MEKBAL Jul 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there is non way.



cmake_minimum_required (VERSION 3.20)

project(Test_Counter)

find_package(Python3 COMPONENTS Interpreter REQUIRED)

add_executable(test_verificarlo Test_Frontend_executable.cpp)
add_executable(test_verrou Test_Frontend_executable.cpp)

set_property(TARGET test_verrou PROPERTY CXX_STANDARD 17)

set(PYTHON_SCRIPT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/test_counter.py)
get_filename_component(PARENT_DIR ${CMAKE_SOURCE_DIR} DIRECTORY)
get_filename_component(GRANDPARENT_DIR ${PARENT_DIR} DIRECTORY)
get_filename_component(GRAND_GRAND_DIR ${GRANDPARENT_DIR} DIRECTORY)
set(PIN_PATH ${PARENT_DIR}/pene_files/PENE/Pin/Linux/pin)
set(LIB_PATH ${PARENT_DIR}/pene_files/PENE/src/libpene.so)

# set(CMAKE_GENERICS_PATH "${CMAKE_SOURCE_DIR}")

set(new_back_verificarlo ${PARENT_DIR}/verificarlo_files/backends_so/libtarget_backend_test_2.so)

set(TOOL_PATH ${PARENT_DIR}/pene_files/PENE/cmake/tools)

add_custom_command(
TARGET test_verificarlo
PRE_BUILD
COMMAND verificarlo-c++ ${CMAKE_CURRENT_SOURCE_DIR}/Test_Frontend_executable.cpp -o ${CMAKE_CURRENT_BINARY_DIR}/verificarlo_exe
COMMENT "Building verificarlo_exe"
)

add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_counter.py
COMMAND ${CMAKE_COMMAND}
-D INFILE=${CMAKE_CURRENT_SOURCE_DIR}/test_counter.py
-D OUTFILE=${CMAKE_CURRENT_BINARY_DIR}/test_counter.py
-D REPLACE_TESTS_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}
-D VERIFICARLO_EXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/verificarlo_exe
-D BACKEND_VERIFICARLO=${new_back_verificarlo}
-D VERROU_EXECUTABLE=$<TARGET_FILE:test_verrou>
-D LIB=${LIB_PATH}
-D PIN_EXECUTABLE=${PIN_PATH}
-P ${CMAKE_GENERICS_PATH}/GenericConfigureFile.cmake
DEPENDS
${CMAKE_GENERICS_PATH}/GenericConfigureFile.cmake
COMMENT "Configuring test_replace.py"
VERBATIM
)


set(TEST_SCRIPTS test_counter.py)

list(TRANSFORM TEST_SCRIPTS PREPEND ${CMAKE_CURRENT_BINARY_DIR}/)
add_custom_target(${PROJECT_NAME} ALL DEPENDS
${TEST_SCRIPTS}
${CMAKE_CURRENT_BINARY_DIR}/test_counter.py
)

enable_testing()


option(TEST_PENE "Enable testing for PENE" OFF)
option(TEST_VERIFICARLO "Enable testing for Verificarlo" OFF)

set(PENE_TESTS test_Nbr_Op_PENE)
set(VERIFICARLO_TESTS test_Nbr_Op_Verificarlo)

set(TEST_LIST)

if(TEST_PENE)
list(APPEND TEST_LIST ${PENE_TESTS})
endif()

if(TEST_VERIFICARLO)
list(APPEND TEST_LIST ${VERIFICARLO_TESTS})
endif()


if(NOT "${TEST_LIST}" STREQUAL "")
foreach(test ${TEST_LIST})
add_test(NAME ${test}
COMMAND ${Python3_EXECUTABLE} -m pytest -k ${test} ${CMAKE_CURRENT_BINARY_DIR}/test_counter.py
)
endforeach()
else()
message(WARNING "No tests specified. Please enable either TEST_PENE or TEST_VERIFICARLO to run specific tests.")
endif()


include_directories("../../../pene_files/PENE/Pin/Linux")
include_directories("../../../pene_files/PENE/src")
Loading
Loading