Skip to content

Conversation

@Bsaileh
Copy link

@Bsaileh Bsaileh commented Oct 21, 2024

Add infrastructure for SMTP and POP test coverage

  • Integrated clang coverage tool into the project build process to enable test coverage reporting.
    Currently, the coverage tools operate only on pop3.c and smtp.c.
    To collect coverage the following commands must be run:

    • export COVERAGE=1
    • podman-compose build
    • ./test.sh (Note: it is recommended to wait a bit until the servers are up and running)
    • ./collect_pop_smtp_coverage.sh
      To turn off coverage, the variable COVERAGE must not be present or be of value 0.
  • Notes:

    • In order to support coverage it was needed to build and execute the relevant binaries in the same build stage (the last) of the container
    • You may need to use sudo with the coverage collecting tool because the volume containing the raw coverage data may be protected.

 - Integrated clang coverage tool into the project build process to enable test coverage reporting.
   Currently, the coverage tools operate only on pop3.c and smtp.c.
   To collect coverage the following commands must be run:
      - export COVERAGE=1
      - podman-compose build
      - ./test.sh (Note: it is recommended to wait a bit until the servers are up and running)
      - ./collect_pop_smtp_coverage.sh
   To turn off coverage, the variable COVERAGE must not be present or be of value 0.

 - Note that in order to support coverage it was needed to build and execute the relevant binaries in
   the same build stage (the last) of the container

Signed-off-by: BasharRadya <basharabdelgafer@gmail.com>
Signed-off-by: Bsaileh <osama.b@campus.technion.ac.il>
@Bsaileh Bsaileh force-pushed the smtp_pop_coverage_infrastructure branch from 6e84c84 to 067256f Compare October 21, 2024 18:33
@Bsaileh
Copy link
Author

Bsaileh commented Oct 21, 2024

For the code to work the folder containing the source code must be named singularity.

@theyoyojo
Copy link
Contributor

Hey, sorry for not getting back to you sooner.

I was able to get this to work for me with some slight changes to your script:

diff --git a/collect_coverage.sh b/collect_coverage.sh
index 9912841..1f5956f 100755
--- a/collect_coverage.sh
+++ b/collect_coverage.sh
@@ -23,6 +23,6 @@ podman exec -u 0 -it $CONTAINER_NAME /bin/bash -c '
     cp ./'$SRC_NAME' '$BUILD_PATH'/'$SRC_NAME'
     llvm-cov show /usr/local/bin/'$EXC_NAME' -instr-profile=coverage.profdata -format=html -output-dir=./cov
 '
-cp -r /var/lib/containers/storage/volumes/$VOLUME_NAME/_data/cov/* $DEST_DIR
-chown 100:100 -R $DEST_DIR
-chmod 777 -R $DEST_DIR
\ No newline at end of file
+cp -r ~/.local/share/containers/storage/volumes/$VOLUME_NAME/_data/cov/* $DEST_DIR
+chown $USER:$USER -R $DEST_DIR
+chmod 777 -R $DEST_DIR

This way nothing required root permissions.

I think the /var/lib... path is used for containers running as superuser but I'm not sure. Worth looking into

Also the 100:100 user would only work when the user has that ID, so I just substituted the current user.

Lastly, the chmod 777 is probably overkill and can be scaled back.

Nice to be able to see test coverage though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants