Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "CI"

on:
push:
branches:
- main

pull_request:

jobs:
checks:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.12'
cache: 'pip'
- run: pip install -r requirements.txt
- name: Checks
uses: pre-commit/action@v3.0.0

gcc:
runs-on: 'ubuntu-latest'
strategy:
matrix:
cxx: [gcc, clang]
name: ${{ matrix.cxx }}
env:
CXX: ${{ matrix.cxx }}
steps:
- uses: actions/checkout@v4
- name: CMake
run: |
sudo apt-get update
sudo apt-get install libhdf5-dev
cmake -B build
- name: Build
run: make -C build -j `nproc`
- name: Test
run: ctest --test-dir ./build/test/bash
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ target_link_libraries(${PROJECT_NAME} INTERFACE cjson)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
add_subdirectory(examples)
add_subdirectory(test)
endif()
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(bash)
30 changes: 30 additions & 0 deletions test/bash/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function(download_data url file_name)
set(DATASET_ARCHIVE ${CMAKE_BINARY_DIR}/data/${file_name})

file(DOWNLOAD
${url}
${DATASET_ARCHIVE})
endfunction()

download_data(https://suitesparse-collection-website.herokuapp.com/MM/DIMACS10/chesapeake.tar.gz
chesapeake.tar.gz)

download_data(https://suitesparse-collection-website.herokuapp.com/MM/HB/1138_bus.tar.gz
1138_bus.tar.gz)

download_data(https://suitesparse-collection-website.herokuapp.com/MM/Belcastro/mouse_gene.tar.gz
mouse_gene.tar.gz)

download_data(https://suitesparse-collection-website.herokuapp.com/MM/Pajek/IMDB.tar.gz
IMDB.tar.gz)

find_program(BASH_PROGRAM bash)

enable_testing()

if(BASH_PROGRAM)
add_test(NAME integration.chesapeake COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/test.sh ${CMAKE_BINARY_DIR}/data/chesapeake.tar.gz)
add_test(NAME integration.1138_bus COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/test.sh ${CMAKE_BINARY_DIR}/data/1138_bus.tar.gz)
add_test(NAME integration.mouse_gene COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/test.sh ${CMAKE_BINARY_DIR}/data/mouse_gene.tar.gz)
add_test(NAME integration.IMDB COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/test.sh ${CMAKE_BINARY_DIR}/data/IMDB.tar.gz)
endif()
103 changes: 103 additions & 0 deletions test/bash/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/usr/bin/env bash
set -e

convert_ssmc() {
echo "unpacking $1"
fpath=$1

format=$2

if [ -z "$format" ]
then
format=COO
else
format=$2
fi

format_string=`echo ${format} | tr '[:upper:]' '[:lower:]'`

echo "Writing in format ${format}."

fname=`basename ${fpath}`
directory=`dirname ${fpath}`
tar -xf $fpath -C $directory

matrix_name=${fname/.tar.gz/}

main_matrix=$directory/$matrix_name/$matrix_name.mtx

dest_file=$directory/$matrix_name.${format_string}.bsp.h5

# echo "dest file ${dest_file}"

# echo "Primary matrix is \"${main_matrix}\" -> ${dest_file}/root"
echo "mtx2bsp ${main_matrix} ${dest_file} ${format}"
mtx2bsp ${main_matrix} ${dest_file} ${format}

# Set "null option" to return an empty list if no files match glob.
shopt -s nullglob

for secondary_matrix in ${directory}/${matrix_name}/${matrix_name}_*.mtx
do
# echo "Secondary matrix \"${secondary_matrix}\""
secondary_name=`basename ${secondary_matrix}`
secondary_name=${secondary_name/.mtx/}
secondary_name=${secondary_name/${matrix_name}_/}
echo "mtx2bsp ${secondary_matrix} ${dest_file}:${secondary_name}"
mtx2bsp ${secondary_matrix} ${dest_file}:${secondary_name}
done

rm -r ${directory}/${matrix_name}
}

check_ssmc() {
echo "unpacking $1"
fpath=$1

format=$2

if [ -z "$format" ]
then
format=COO
else
format=$2
fi

format_string=`echo ${format} | tr '[:upper:]' '[:lower:]'`

fname=`basename ${fpath}`
directory=`dirname ${fpath}`
tar -xf $fpath -C $directory

matrix_name=${fname/.tar.gz/}

main_matrix=$directory/$matrix_name/$matrix_name.mtx

dest_file=$directory/$matrix_name.${format_string}.bsp.h5

# echo "dest file ${dest_file}"

# echo "Primary matrix is \"${main_matrix}\" -> ${dest_file}/root"
echo "check_equivalence ${main_matrix} ${dest_file}"
check_equivalence ${main_matrix} ${dest_file}

# Set "null option" to return an empty list if no files match glob.
shopt -s nullglob

for secondary_matrix in ${directory}/${matrix_name}/${matrix_name}_*.mtx
do
# echo "Secondary matrix \"${secondary_matrix}\""
secondary_name=`basename ${secondary_matrix}`
secondary_name=${secondary_name/.mtx/}
secondary_name=${secondary_name/${matrix_name}_/}
echo "check_equivalence ${secondary_matrix} ${dest_file}:${secondary_name}"
check_equivalence ${secondary_matrix} ${dest_file}:${secondary_name}
done

rm -r ${directory}/${matrix_name}
}

export PATH=$PATH:$PWD/../../examples

convert_ssmc $1 COO
check_ssmc $1 COO