TornadoVM icon indicating copy to clipboard operation
TornadoVM copied to clipboard

Migrate from JUnit 4 to JUnit 5

Open mikepapadim opened this issue 11 months ago • 11 comments

Description

Describe the patch. What does it enhance? What does it fix?

This PR implements the migration unit testing framework from JUnit 4 (JUnit 4.13.2 last updated Feb 13, 2021) to JUnit 5. This migration includes updating dependencies, annotations, assertions, and test instance lifecycle management.

Key changes:

  • Updated Dependencies: Updated the Maven dependencies to include JUnit 5 libraries (junit-jupiter-api, junit-jupiter-engine).
  • Annotations Updates: Migrated JUnit 4 annotations to their JUnit 5 counterparts (e.g., @Before to @BeforeEach, @After to @AfterEach, @BeforeClass to @BeforeAll, @AfterClass to @AfterAll).
  • Assertions Updates: Transitioned to JUnit 5's assertion API which offers better assertion capabilities and error messages (org.junit.jupiter.api.Assertions).

Backend/s tested

Mark the backends affected by this PR.

  • [x] OpenCL
  • [x] PTX
  • [x] SPIRV

OS tested

Mark the OS where this PR is tested.

  • [x] Linux
  • [ ] OSx
  • [ ] Windows

How to test the new patch?

make 
make tests

mikepapadim avatar Mar 18 '24 09:03 mikepapadim

@mikepapadim , if you solve the conflicts, we can merge this PR

jjfumero avatar Mar 21 '24 13:03 jjfumero

@mikepapadim , if you solve the conflicts, we can merge this PR

Lets hold this one.

I solved the conflicts with the latest develop, but now it seems that TestBatches cause a segfault

tornado -ea  --jvm "-Xmx6g -Dtornado.recover.bailout=False -Dtornado.unittests.verbose=True "  -m  tornado.unittests/uk.ac.manchester.tornado.unittests.tools.TornadoTestRunner  --params "uk.ac.manchester.tornado.unittests.batches.TestBatches"
WARNING: Using incubator modules: jdk.incubator.vector
Aborted (core dumped)

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007664629adb68, pid=79598, tid=79624
#
# JRE version: OpenJDK Runtime Environment (21.0+35) (build 21+35-2513)
# Java VM: OpenJDK 64-Bit Server VM (21+35-2513, mixed mode, tiered, jvmci, parallel gc, linux-amd64)
# Problematic frame:
# C  [libnvidia-opencl.so.1+0x1adb68]
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /home/mikepapadim/manchester/TornadoVM/core.79598)
#
# An error report file with more information is saved as:
# /home/mikepapadim/manchester/TornadoVM/hs_err_pid79598.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#

The rest of the tests are in par with develop:

==================================================
              Unit tests report 
==================================================

{'[PASS]': 565, '[FAILED]': 7, '[UNSUPPORTED]': 30}
Coverage [PASS/(PASS+FAIL)]: 98.78%
Coverage [PASS/(PASS+FAIL+UNSUPPORTED)]: 93.85%

==================================================

mikepapadim avatar Mar 21 '24 13:03 mikepapadim

[Update] SegFault also occurs with PTX for TestBatches

mikepapadim avatar Mar 25 '24 16:03 mikepapadim

[Update] I merged it with the latest develop to check the event fix-up if it influences the batch processing failures. Only, @gigiblender patch fixed the issue with batch processing, however, lazy copy-outs still fail. Batch processing on PTX is still failing.

mikepapadim avatar Apr 29 '24 10:04 mikepapadim

Thanks @gigiblender for the patch

mikepapadim avatar May 21 '24 10:05 mikepapadim

@jjfumero @stratika @mairooni when you have time can we do another iteration on testing,.

Now, it it stable to merge after we test it.

mikepapadim avatar May 21 '24 10:05 mikepapadim

Let's check in OSx and Windows as well.

jjfumero avatar May 22 '24 09:05 jjfumero

The batch processing with PTX still failing:

tornado -ea  --jvm "-Xmx6g -Dtornado.recover.bailout=False -Dtornado.unittests.verbose=True "  -m  tornado.unittests/uk.ac.manchester.tornado.unittests.tools.TornadoTestRunner  --params "uk.ac.manchester.tornado.unittests.batches.TestBatches"
WARNING: Using incubator modules: jdk.incubator.vector
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007faeb1d79937, pid=53407, tid=53408
#
# JRE version: Java(TM) SE Runtime Environment (21.0.3+7) (build 21.0.3+7-LTS-152)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21.0.3+7-LTS-152, mixed mode, tiered, jvmci, parallel gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x979937]  jni_GetArrayLength+0x87
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to /home/juan/tornadovm/TornadoVM/core.53407)
#
# An error report file with more information is saved as:
# /home/juan/tornadovm/TornadoVM/hs_err_pid53407.log
[6.098s][warning][os] Loading hsdis library failed
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#

jjfumero avatar May 22 '24 09:05 jjfumero

The batch processing with PTX still failing:

tornado -ea  --jvm "-Xmx6g -Dtornado.recover.bailout=False -Dtornado.unittests.verbose=True "  -m  tornado.unittests/uk.ac.manchester.tornado.unittests.tools.TornadoTestRunner  --params "uk.ac.manchester.tornado.unittests.batches.TestBatches"
WARNING: Using incubator modules: jdk.incubator.vector
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007faeb1d79937, pid=53407, tid=53408
#
# JRE version: Java(TM) SE Runtime Environment (21.0.3+7) (build 21.0.3+7-LTS-152)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21.0.3+7-LTS-152, mixed mode, tiered, jvmci, parallel gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x979937]  jni_GetArrayLength+0x87
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to /home/juan/tornadovm/TornadoVM/core.53407)
#
# An error report file with more information is saved as:
# /home/juan/tornadovm/TornadoVM/hs_err_pid53407.log
[6.098s][warning][os] Loading hsdis library failed
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#

thats weird cause in my configuration with Driver Version: 550.67 CUDA Version: 12.4 it works

mikepapadim avatar May 22 '24 10:05 mikepapadim

@jjfumero @stratika @mairooni I did another iteration on this one to sync it with the latest develop. Batches now pass without causing a segfault.

However, now multithreaded.TestMultiThreadedExecutionPlans causes a segfault.

Also, I updated the version of JUNIT5 to the latest as per 5.11.0.

mikepapadim avatar Sep 04 '24 08:09 mikepapadim

Thanks @mikepapadim . Let's sync next week to tackle this.

jjfumero avatar Sep 04 '24 15:09 jjfumero