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

feat: check supported testcases in CI #85

Merged
merged 20 commits into from
Dec 26, 2024
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
21 changes: 4 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: Rap-booting and testing

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

env:
CARGO_TERM_COLOR: always
Expand All @@ -21,22 +19,11 @@ jobs:
- name: Code Formatting Check
run: cd rap && cargo fmt --check

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install ninja
run: |
pip install ninja

- name: Build RAP
run: |
chmod +x ./install.sh
./install.sh
run: ./install.sh

- run: sudo apt install colorized-logs -y # Insall ansi2txt

- name: Check test cases
run: cd tests && cargo +nightly-2024-10-12 rap -F -M
run: cd tests && ./batch.sh -F -M

- name: Check rap
run: cd rap && cargo +nightly-2024-10-12 rap -F -M
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.vscode/
target/
Cargo.lock
rap.txt
85 changes: 2 additions & 83 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,87 +2,6 @@

set -e

# Define color variables
BLUE='\033[0;34m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
cargo install --path rap

cd rap && cargo clean

case "$SHELL" in
*zsh)
printf "Detecting shell context success: running on %bZsh%b.\n" "${BLUE}" "${NC}"
export SHELL_CONFIG=~/.zshrc
;;
*bash)
printf "Detecting shell context success: running on %bBash%b.\n" "${BLUE}" "${NC}"
export SHELL_CONFIG=~/.bashrc
;;
*)
printf "%bDetecting shell context failed.%b\n" "${RED}" "${NC}"
exit 1
;;
esac

# Set the library path to be added
#LIBRARY_PATH="$HOME/.rustup/toolchains/nightly-2023-10-05-x86_64-unknown-linux-gnu/lib"
toolchain_date="nightly-2024-10-12"
toolchain_file="rust-toolchain.toml"
if [ ! -f "$toolchain_file" ]; then
printf "%bError: %s does not exist.%b\n" "${RED}" "$toolchain_file" "${NC}"
exit 1
fi

if ! rustup toolchain install "$toolchain_date" --profile minimal --component rustc-dev,rust-src,llvm-tools-preview; then
printf "%bError: Failed to install toolchain %s.%b\n" "${RED}" "$toolchain_date" "${NC}"
exit 1
fi

os_type=$(uname -s)
arch_type=$(uname -m)

if [ "$os_type" = "Linux" ]; then
# Update the channel field in rust-toolchain.toml
toolchain="$toolchain_date-x86_64-unknown-linux-gnu"
toolchain_lib="$HOME/.rustup/toolchains/$toolchain/lib"
printf "%bDetected OS: Linux. Setting toolchain to %s%b\n" "${BLUE}" "$toolchain" "${NC}"
sed -i.bak "s/^channel = \".*\"/channel = \"$toolchain\"/" "$toolchain_file"

if ! grep -q "LD_LIBRARY_PATH.*$toolchain_lib" "$SHELL_CONFIG"; then
if grep -q "LD_LIBRARY_PATH" "$SHELL_CONFIG"; then
export LD_LIBRARY_PATH="$toolchain_lib:$LD_LIBRARY_PATH"
sed -i '/LD_LIBRARY_PATH/d' "$SHELL_CONFIG"
printf "%bOld LD_LIBRARY_PATH definition has been removed from %s.%b\n" "${GREEN}" "$SHELL_CONFIG" "${NC}"
else
export LD_LIBRARY_PATH="$toolchain_lib"
fi
echo "export LD_LIBRARY_PATH=\"${LD_LIBRARY_PATH}\"" >> "$SHELL_CONFIG"
printf "%bEnvironment variables have been successfully written to %s.%b\n" "${GREEN}" "$SHELL_CONFIG" "${NC}"
fi
elif [ "$os_type" = "Darwin" ]; then
if [ "$arch_type" = "x86_64" ]; then
toolchain="$toolchain_date-x86_64-apple-darwin"
toolchain_lib="$HOME/.rustup/toolchain/$toolchain/lib"
else
toolchain="$toolchain_date-aarch64-apple-darwin"
toolchain_lib="$HOME/.rustup/toolchain/$toolchain/lib"
fi
printf "%bDetected OS: macOS. Setting toolchain to %s%b\n" "${BLUE}" "$toolchain" "${NC}"
sed -i.bak "s/^channel = \".*\"/channel = \"$toolchain\"/" "$toolchain_file"

if ! grep -q "DYLD_LIBRARY_PATH.*$toolchain_lib" "$SHELL_CONFIG"; then
if grep -q "DYLD_LIBRARY_PATH" "$SHELL_CONFIG"; then
export DYLD_LIBRARY_PATH="$toolchain_lib:$DYLD_LIBRARY_PATH"
sed -i '/DYLD_LIBRARY_PATH/d' "$SHELL_CONFIG"
printf "%bOld DYLD_LIBRARY_PATH definition has been removed from %s.%b\n" "${GREEN}" "$SHELL_CONFIG" "${NC}"
else
export DYLD_LIBRARY_PATH="$toolchain_lib"
fi
echo "export DYLD_LIBRARY_PATH=\"${DYLD_LIBRARY_PATH}\"" >> "$SHELL_CONFIG"
printf "%bEnvironment variables have been successfully written to %s.%b\n" "${GREEN}" "$SHELL_CONFIG" "${NC}"
fi
fi

cargo install --path .

printf "%bTo apply the changes, you may need to run: %bsource %s%b\n" "${GREEN}" "${BLUE}" "$SHELL_CONFIG" "${NC}"
cargo rap -help
File renamed without changes.
35 changes: 0 additions & 35 deletions tests/CI_leak/batch.sh

This file was deleted.

35 changes: 0 additions & 35 deletions tests/CI_uaf/batch.sh

This file was deleted.

55 changes: 30 additions & 25 deletions tests/batch.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
#!/bin/bash
#该脚本在目录下为每个Cargo项目执行相同的命令直到报错

if [ $# -eq 0 ]; then
# All arguments passed to this script are forwarded to cargo rap

cur=$(pwd)

# 查找并编译当前目录下的所有 Rust 项目
find support -type f -name "Cargo.toml" | while read -r cargo_file; do
# 获取 Cargo.toml 文件所在的目录
project_dir=$(dirname "$cargo_file")

echo "Processing project in: $project_dir"

# 切换到项目目录
pushd "$project_dir" >/dev/null

if [ $# -eq 0 ]; then
#脚本无参数时执行cargo clean
#Example: batch.sh
cmd="cargo clean"
else
$cmd
else
#脚本有参数时按照给定参数执行cargo命令
#Example: batch.sh rap -uaf
cmd="cargo $@"
fi
cmd="cargo rap $@"
$cmd 2>&1 | tee $cur/rap.txt | ansi2txt | grep 'RAP|WARN|' && echo -e "\033[32m$project_dir pass\033[0m"
fi

# 查找并编译当前目录下的所有 Rust 项目
find . -type f -name "Cargo.toml" | while read -r cargo_file; do
# 获取 Cargo.toml 文件所在的目录
project_dir=$(dirname "$cargo_file")

echo "Processing project in: $project_dir"

# 切换到项目目录
pushd "$project_dir" > /dev/null

$cmd
if [ $? -ne 0 ]; then
# 如果命令失败,打印错误信息并退出循环
echo "Error: '$cmd' failed in $project_dir"
popd > /dev/null
exit 1
fi

# 返回原始目录
popd > /dev/null
done
if [ $? -ne 0 ]; then
# 如果命令失败,打印错误信息并退出循环
echo -e "Error: '$cmd' failed in $project_dir \nRAP output:"
cat $cur/rap.txt
popd >/dev/null
exit 1
fi

# 返回原始目录
popd >/dev/null
done
File renamed without changes.
File renamed without changes.
File renamed without changes.