Skip to content

Commit

Permalink
add build/test script for getdcmtags
Browse files Browse the repository at this point in the history
update getdcmtag binaries
  • Loading branch information
Roy Wiggins authored and Roy Wiggins committed Nov 22, 2024
1 parent 7dd42e7 commit 71e5255
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 0 deletions.
Binary file modified bin/ubuntu20.04/getdcmtags
Binary file not shown.
Binary file modified bin/ubuntu22.04/getdcmtags
Binary file not shown.
Binary file modified bin/ubuntu24.04/getdcmtags
Binary file not shown.
21 changes: 21 additions & 0 deletions getdcmtags/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARG UBUNTU_VERSION=22.04
FROM ubuntu:${UBUNTU_VERSION}
ENV DEBIAN_FRONTEND=noninteractive
# Install necessary packages
RUN apt-get update && apt-get install -y \
build-essential \
qtbase5-dev \
dcmtk \
libdcmtk-dev \
jq \
&& rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

# Copy the project files into the container
COPY . .
RUN mkdir /build

# Set the default command
CMD qmake && make && ./test.sh && cp getdcmtags /build
52 changes: 52 additions & 0 deletions getdcmtags/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
set -euo pipefail

build_docker_image() {
local UBUNTU_VERSION=$1

echo "Building Docker image for Ubuntu $UBUNTU_VERSION"

# Build the Docker image
docker build --build-arg UBUNTU_VERSION=$UBUNTU_VERSION -t mercure-getdcmtags-build:$UBUNTU_VERSION .

if [ $? -ne 0 ]; then
echo "Docker build failed for Ubuntu $UBUNTU_VERSION"
return 1
fi

echo "Docker image for Ubuntu $UBUNTU_VERSION built successfully"
echo "----------------------------------------"
}


build_qt_project() {
local UBUNTU_VERSION=$1

echo "Building for Ubuntu $UBUNTU_VERSION"

docker run -it mercure-getdcmtags-build:$UBUNTU_VERSION
local last_container=$(docker ps -lq)
docker cp $last_container:/build/getdcmtags ../bin/ubuntu${UBUNTU_VERSION}/getdcmtags
docker rm $last_container

echo "Build for Ubuntu $UBUNTU_VERSION completed"
echo "----------------------------------------"
}

# Main execution
echo "Starting getdcmtags build"
echo "======================================================="

# Build for each Ubuntu version
for VERSION in 20.04 22.04 24.04; do
build_docker_image $VERSION
done

# Run builds and extract executables for each Ubuntu version
for VERSION in 20.04 22.04 24.04; do
build_qt_project $VERSION
done



echo "All builds completed"
46 changes: 46 additions & 0 deletions getdcmtags/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
set -euo pipefail

echo "Testing"
cp test_dcm test_dcm_copy
./getdcmtags test_dcm_copy sender_address sender_aet receiver_aet 0.0.0.0 asdf --set-tag forceKey=forcedValue
uid="1.2.276.0.7230010.3.1.3.9022104837472469675953272569912339663578"
if [ ! -e $uid/$uid#test_dcm_copy.tags ]; then
echo "Failed to create tags file"
exit 1
fi


check_key() {
local key="$1"
local expected_value="$2"
local actual_value=$(jq -r ".$key // \"__NULL__\"" "$uid/$uid#test_dcm_copy.tags")

if [ "$actual_value" == "__NULL__" ]; then
cat $uid/$uid#test_dcm_copy.tags
echo "Key '$key' not found in the JSON file."
echo "Test failed"
exit 1
elif [ "$actual_value" == "$expected_value" ]; then
return
# echo "Key '$key' matches expected value: $actual_value"
else
cat $uid/$uid#test_dcm_copy.tags
echo "Key '$key' does not match. Expected: $expected_value, Actual: $actual_value"
echo "Test failed"
exit 1
fi
}


check_key "Filename" "test_dcm_copy"
check_key "SenderAddress" "sender_address"
check_key "SenderAET" "sender_aet"
check_key "ReceiverAET" "receiver_aet"
check_key "SeriesInstanceUID" "$uid"
check_key "forceKey" "forcedValue"

rm -f test_dcm_copy
rm -rf $uid

echo "Success"
Binary file added getdcmtags/test_dcm
Binary file not shown.

0 comments on commit 71e5255

Please sign in to comment.