Repository: IntelPython/numba-dpex (language: python)

Issue:
Run GDB tests for numba-dpex on public GitHub Actions
We want to run [numba_dpex/tests/debugging](https://github.com/IntelPython/numba-dpex/tree/main/numba_dpex/tests/debugging) tests on every Pull Request. That tests being run in [.github/workflows/conda-package.yml#L189-L191](https://github.com/IntelPython/numba-dpex/blob/main/.github/workflows/conda-package.yml#L189-L191). We need to add [Oneapi GDB](https://www.intel.com/content/www/us/en/developer/tools/oneapi/distribution-for-gdb.html) into this environment in order to run those tests.

Implementation proposal:
1. After [setting up conda environment](https://github.com/IntelPython/numba-dpex/blob/main/.github/workflows/conda-package.yml#L122-L123) install Oneapi GDB. Since it is not available as a conda package preferred way is to use [standalone version](https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html#distributiongdb). Job should run something like:
```bash
wget -nc -q $ONEAPI_INSTALLER_URL/$ONEAPI_INSTALL_BINARY_NAME 
chmod +x $ONEAPI_INSTALL_BINARY_NAME
./$ONEAPI_INSTALL_BINARY_NAME -a -s --eula accept \
  --action install --components $ONEAPI_COMPONENTS  \
  --install-dir $ONEAPI_INSTALL_DIR --log-dir $ONEAPI_LOG_DIR \
  --download-cache $ONEAPI_CACHE_DIR
``` 

Use `--help` instructions to see available option. Also see the output of the install since you need to add installed binaries to [PATH](https://www.linfo.org/path_env_var.html).

2. As my understanding right some of those tests are failing now. Open issue that describes what tests are failing and why, mute them and add link to the issue in the comment that states why they are muted. We must target those issues in separate PRs.

PS: this is how link to installer should look:
https://registrationcenter-download.intel.com/akdlm/IRC_NAS/fcea1bcd-6a63-4849-b304-906ff71dc2c0/l_dpcpp_dbg_p_2023.2.0.49333.sh



Discussion / hints:

Fix patch:
diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml
index 946e33796e..5a1a465216 100644
--- a/.github/workflows/conda-package.yml
+++ b/.github/workflows/conda-package.yml
@@ -44,7 +44,7 @@ jobs:
           access_token: ${{ github.token }}
 
       - name: Checkout ${{ env.PACKAGE_NAME }} repo
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
         with:
           fetch-depth: 0
 
@@ -105,6 +105,10 @@ jobs:
         os: [ubuntu-20.04, ubuntu-latest, windows-latest]
         experimental: [false]
         use_mlir: [false]
+        run_gdb: [true, false]
+        exclude:
+          - os: windows-latest
+            run_gdb: true
 
     continue-on-error: ${{ matrix.experimental || matrix.use_mlir }}
 
@@ -168,7 +172,7 @@ jobs:
       # We want to make sure that all dependecies install automatically.
       # intel::intel-opencl-rt is needed for set-intel-ocl-icd-registry.ps1
       - name: Install builded package
-        run: mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} intel::intel-opencl-rt pytest -c ${{ env.CHANNEL_PATH }}
+        run: mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} intel::intel-opencl-rt pytest-cov -c ${{ env.CHANNEL_PATH }}
 
       - name: Install numba-mlir
         if: matrix.use_mlir
@@ -181,6 +185,13 @@ jobs:
           $script_path="$env:CONDA_PREFIX\Scripts\set-intel-ocl-icd-registry.ps1"
           &$script_path
 
+      - name: Checkout setup config
+        uses: actions/checkout@v4
+        with:
+          sparse-checkout: |
+            pyproject.toml
+          sparse-checkout-cone-mode: false
+
       - name: List installed packages
         run: conda list
 
@@ -194,12 +205,14 @@ jobs:
         run: python -c "import dpnp, dpctl, numba_dpex; dpctl.lsplatform()"
 
       - name: Run tests
+        if: ${{!matrix.run_gdb}}
         env:
           NUMBA_DPEX_USE_MLIR: ${{ matrix.use_mlir && '1' || '0'  }}
         run: |
           pytest -q -ra --disable-warnings --pyargs ${{ env.MODULE_NAME }} -vv
 
       - name: Run examples
+        if: ${{!matrix.run_gdb}}
         shell: bash -l {0}
         run: |
           cd ${{ env.EXAMPLES_PATH }}
@@ -209,6 +222,21 @@ jobs:
             python ${script} || exit 1
           done
 
+      - name: Run gdb tests
+        if: ${{matrix.run_gdb}}
+        env:
+          GDB_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/fcea1bcd-6a63-4849-b304-906ff71dc2c0/l_dpcpp_dbg_p_2023.2.0.49333_offline.sh
+          GDB_INSTALLER: l_dpcpp_dbg_p_2023.2.0.49333_offline.sh
+        run: |
+          conda install pexpect
+          wget -nc -q ${{ env.GDB_URL }}
+          chmod +x ${{ env.GDB_INSTALLER }}
+          mkdir /tmp/gdb
+          export ONEAPI_ROOT=/tmp/gdb
+          ./${{ env.GDB_INSTALLER }} -a -s --eula accept --install-dir $ONEAPI_ROOT
+          source $ONEAPI_ROOT/debugger/latest/env/vars.sh
+          pytest -q -ra --disable-warnings --pyargs ${{ env.MODULE_NAME }}.tests.debugging -vv
+
   upload_anaconda:
     name: Upload dppy/label/dev ['${{ matrix.os }}', python='${{ matrix.python }}']
     if: ${{github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/heads/release') == true)}}
@@ -285,7 +313,7 @@ jobs:
         run: conda install anaconda-client
 
       - name: Checkout repo
-        uses: actions/checkout@v2
+        uses: actions/checkout@v4
         with:
           repository: IntelPython/devops-tools
           fetch-depth: 0


Test patch:
diff --git a/numba_dpex/tests/debugging/test_backtraces.py b/numba_dpex/tests/debugging/test_backtraces.py
index b38a8d8320..b07418ca18 100644
--- a/numba_dpex/tests/debugging/test_backtraces.py
+++ b/numba_dpex/tests/debugging/test_backtraces.py
@@ -8,6 +8,7 @@
 
 https://www.sourceware.org/gdb/onlinedocs/gdb/Backtrace.html
 """
+import pytest
 
 from numba_dpex.tests._helper import skip_no_gdb
 
@@ -16,6 +17,7 @@
 pytestmark = skip_no_gdb
 
 
+@pytest.mark.xfail  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
 def test_backtrace(app):
     """Simple test for backtrace.
 
diff --git a/numba_dpex/tests/debugging/test_breakpoints.py b/numba_dpex/tests/debugging/test_breakpoints.py
index d4296b3495..4c967820ab 100644
--- a/numba_dpex/tests/debugging/test_breakpoints.py
+++ b/numba_dpex/tests/debugging/test_breakpoints.py
@@ -57,6 +57,11 @@ def test_breakpoint_with_condition_by_function_argument(app, breakpoint, api):
     Test for https://github.com/numba/numba/issues/7415
     SAT-4449
     """
+    if api == "numba-dpex-kernel":
+        pytest.xfail(
+            "Wrong name for kernel api."
+        )  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
+
     variable_name = "param_a"
     variable_value = "3"
     condition = f"{variable_name} == {variable_value}"
@@ -73,6 +78,7 @@ def test_breakpoint_with_condition_by_function_argument(app, breakpoint, api):
     app.child.expect(rf"\$1 = {variable_value}")
 
 
+@pytest.mark.xfail  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
 @pytest.mark.parametrize(
     "breakpoint, script",
     [
diff --git a/numba_dpex/tests/debugging/test_common.py b/numba_dpex/tests/debugging/test_common.py
index a4bc2a8e5d..7993001b86 100644
--- a/numba_dpex/tests/debugging/test_common.py
+++ b/numba_dpex/tests/debugging/test_common.py
@@ -50,4 +50,12 @@ def test_breakpoint_by_function(file_name, function, expected):
 def test_setup_breakpoint(
     app, breakpoint, script, expected_location, expected_line
 ):
+    if (
+        breakpoint == "simple_sum.py:data_parallel_sum"
+        or breakpoint == "data_parallel_sum"
+    ):
+        pytest.xfail(
+            "Expected failures for these files."
+        )  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
+
     setup_breakpoint(app, breakpoint, script, expected_location, expected_line)
diff --git a/numba_dpex/tests/debugging/test_info.py b/numba_dpex/tests/debugging/test_info.py
index 8d892439df..a7f084ca94 100644
--- a/numba_dpex/tests/debugging/test_info.py
+++ b/numba_dpex/tests/debugging/test_info.py
@@ -70,6 +70,13 @@ def test_info_args(
     Issue: https://github.com/numba/numba/issues/7414
     Fix: https://github.com/numba/numba/pull/7177
     """
+    if (
+        script == "simple_dpex_func.py"
+        or script == "side-by-side.py --api=numba-dpex-kernel"
+    ):
+        pytest.xfail(
+            "Expected Failure for these files."
+        )  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
 
     setup_breakpoint(app, breakpoint, script, expected_line=expected_line)
 
@@ -90,6 +97,7 @@ def test_info_args(
     app.child.expect(expected_whatis)
 
 
+@pytest.mark.xfail  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
 @skip_no_numba056
 def test_info_functions(app):
     expected_line = r"13\s+i = dpex.get_global_id\(0\)"
@@ -145,7 +153,7 @@ def side_by_side_2_info_locals_case(api):
 @pytest.mark.parametrize(
     "env, breakpoint, script, expected_line, expected_info_locals, expected_info",
     [
-        (
+        pytest.param(
             {"NUMBA_OPT": 0},
             "sum_local_vars.py:16",
             "sum_local_vars.py",
@@ -175,6 +183,7 @@ def side_by_side_2_info_locals_case(api):
                     r"type = float64",
                 ),
             ),
+            marks=pytest.mark.xfail,
         ),
         # FIXME: NUMBA_OPT=1 will not able to stop at breakpoint
         pytest.param(
@@ -184,36 +193,42 @@ def side_by_side_2_info_locals_case(api):
             r"16\s+c\[i\] = l1 \+ l2",
             ("No locals.",),
             (),
-            marks=pytest.mark.xfail,
+            marks=pytest.mark.xfail,  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
         ),
-        (
+        pytest.param(
             {"NUMBA_EXTEND_VARIABLE_LIFETIMES": 1},
             "side-by-side.py:18",
             "side-by-side.py --api=numba-dpex-kernel",
             None,
             (r"param_c = 0", r"param_d = 0", r"result = 10"),
             (),
+            marks=pytest.mark.xfail,  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
         ),
-        (
+        pytest.param(
             {"NUMBA_EXTEND_VARIABLE_LIFETIMES": 0},
             "side-by-side.py:18",
             "side-by-side.py --api=numba-dpex-kernel",
             None,
             (r"param_c = 0", r"param_d = 0", r"result = 10"),
             (),
+            marks=pytest.mark.xfail,  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
         ),
         side_by_side_info_locals_case("numba"),
         pytest.param(
             *side_by_side_info_locals_case("numba-dpex-kernel"),
             marks=[
-                pytest.mark.xfail(reason="dpex isn't stoping with condition")
+                pytest.mark.xfail(
+                    reason="dpex isn't stoping with condition"
+                )  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
             ],
         ),
         side_by_side_2_info_locals_case("numba"),
         pytest.param(
             *side_by_side_2_info_locals_case("numba-dpex-kernel"),
             marks=[
-                pytest.mark.xfail(reason="dpex isn't stoping with condition")
+                pytest.mark.xfail(
+                    reason="dpex isn't stoping with condition"
+                )  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
             ],
         ),
     ],
@@ -277,7 +292,9 @@ def side_by_side_2_print_array_element_case(api):
         pytest.param(
             *side_by_side_2_print_array_element_case("numba-dpex-kernel"),
             marks=[
-                pytest.mark.xfail(reason="dpex isn't stoping with condition")
+                pytest.mark.xfail(
+                    reason="dpex isn't stoping with condition"
+                )  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
             ],
         ),
     ],
@@ -294,6 +311,8 @@ def test_print_array_element(app, breakpoint, script, expected_info):
         app.child.expect(expected_print)
 
 
+# FIXME: crashes test execution
+@pytest.mark.skip  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
 def side_by_side_2_assignment_to_variable_case(api):
     return (
         "side-by-side-2.py:19 if param_a == 5",
@@ -316,7 +335,9 @@ def side_by_side_2_assignment_to_variable_case(api):
         pytest.param(
             *side_by_side_2_assignment_to_variable_case("numba-dpex-kernel"),
             marks=[
-                pytest.mark.xfail(reason="dpex isn't stoping with condition")
+                pytest.mark.xfail(
+                    reason="dpex isn't stoping with condition"
+                )  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
             ],
         ),
     ],
diff --git a/numba_dpex/tests/debugging/test_side_by_side.py b/numba_dpex/tests/debugging/test_side_by_side.py
index 0d7abe2125..3f1181d781 100644
--- a/numba_dpex/tests/debugging/test_side_by_side.py
+++ b/numba_dpex/tests/debugging/test_side_by_side.py
@@ -18,6 +18,11 @@
 def test_breakpoint_row_number(app, api):
     """Test for checking numba and numba-dpex debugging side-by-side."""
 
+    if api == "numba-dpex-kernel":
+        pytest.xfail(
+            "Wrong name for kernel api."
+        )  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
+
     app.breakpoint("side-by-side.py:15")
     app.run("side-by-side.py --api={api}".format(api=api))
 
diff --git a/numba_dpex/tests/debugging/test_stepping.py b/numba_dpex/tests/debugging/test_stepping.py
index 07802679d8..bafda0b298 100644
--- a/numba_dpex/tests/debugging/test_stepping.py
+++ b/numba_dpex/tests/debugging/test_stepping.py
@@ -9,6 +9,8 @@
 https://www.sourceware.org/gdb/onlinedocs/gdb/Continuing-and-Stepping.html
 """
 
+import pytest
+
 from numba_dpex.tests._helper import skip_no_gdb
 
 from .common import setup_breakpoint
@@ -17,6 +19,7 @@
 
 
 # commands/next
+@pytest.mark.xfail  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
 def test_next(app):
     setup_breakpoint(
         app,
@@ -31,6 +34,7 @@ def test_next(app):
 
 
 # commands/step_dpex_func
+@pytest.mark.xfail  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
 def test_step(app):
     setup_breakpoint(
         app,
@@ -46,6 +50,7 @@ def test_step(app):
 
 
 # commands/stepi
+@pytest.mark.xfail  # TODO: https://github.com/IntelPython/numba-dpex/issues/1216
 def test_stepi(app):
     setup_breakpoint(
         app,