Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[lldb][test] Fix beginning/end of file test failed on Windows #139278

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hapeeeeee
Copy link
Contributor

As @DavidSpickett mentioned, this change fixed the test failure introduced in #137515, which was caused by the use of platform-specific headers not available on Windows.

This PR does not modify any functional code; it only updates the test cases.

@hapeeeeee hapeeeeee requested a review from JDevlieghere as a code owner May 9, 2025 15:09
@llvmbot llvmbot added the lldb label May 9, 2025
@llvmbot
Copy link
Member

llvmbot commented May 9, 2025

@llvm/pr-subscribers-lldb

Author: Zax (hapeeeeee)

Changes

As @DavidSpickett mentioned, this change fixed the test failure introduced in #137515, which was caused by the use of platform-specific headers not available on Windows.

This PR does not modify any functional code; it only updates the test cases.


Full diff: https://github.com/llvm/llvm-project/pull/139278.diff

3 Files Affected:

  • (added) lldb/test/Shell/Commands/Inputs/cross_platform.c (+31)
  • (modified) lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test (+5-7)
  • (modified) lldb/test/Shell/Commands/command-list-reach-end-of-file.test (+2-7)
diff --git a/lldb/test/Shell/Commands/Inputs/cross_platform.c b/lldb/test/Shell/Commands/Inputs/cross_platform.c
new file mode 100644
index 0000000000000..bcc484eb36ac5
--- /dev/null
+++ b/lldb/test/Shell/Commands/Inputs/cross_platform.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+void bubbleSort(int arr[], int n) {
+  for (int i = 0; i < n - 1; i++) {
+    int swapped = 0;
+    for (int j = 0; j < n - i - 1; j++) {
+      if (arr[j] > arr[j + 1]) {
+        int temp = arr[j];
+        arr[j] = arr[j + 1];
+        arr[j + 1] = temp;
+        swapped = 1;
+      }
+    }
+    if (!swapped)
+      break;
+  }
+}
+
+int main() {
+  int arr[] = {64, 34, 25, 12, 22, 11, 90};
+  int n = sizeof(arr) / sizeof(arr[0]);
+
+  for (int i = 0; i < n; i++)
+    printf("%d ", arr[i]);
+  printf("\n");
+
+  bubbleSort(arr, n);
+  for (int i = 0; i < n; i++)
+    printf("%d ", arr[i]);
+  printf("\n");
+  return 0;
+}
diff --git a/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test b/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
index fa4a93e5904aa..29c33f6fe105e 100644
--- a/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
+++ b/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
@@ -1,6 +1,4 @@
-# Source uses unistd.h.
-# UNSUPPORTED: system-windows
-# RUN: %clang_host -g -O0 %S/Inputs/sigchld.c -o %t.out
+# RUN: %clang_host -g -O0 %S/Inputs/cross_platform.c -o %t.out
 # RUN: %lldb %t.out -b -s %s 2>&1 | FileCheck %s
 
 list
@@ -13,13 +11,13 @@ r
 # CHECK: int main()
 
 list
-# CHECK: if (child_pid == 0)
+# CHECK: bubbleSort(arr, n);
 
 list -
 # CHECK: int main()
 
-list -10
-# CHECK: #include <assert.h>
+list -20
+# CHECK: #include <stdio.h>
 
 list -
 # CHECK: note: Reached beginning of the file, no more to page
@@ -28,4 +26,4 @@ list -
 # CHECK: note: Reached beginning of the file, no more to page
 
 list
-# CHECK: int main()
+# CHECK: bubbleSort(arr, n);
diff --git a/lldb/test/Shell/Commands/command-list-reach-end-of-file.test b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test
index edf4c521a9e76..d6909b85a390b 100644
--- a/lldb/test/Shell/Commands/command-list-reach-end-of-file.test
+++ b/lldb/test/Shell/Commands/command-list-reach-end-of-file.test
@@ -1,6 +1,4 @@
-# Source uses unistd.h.
-# UNSUPPORTED: system-windows
-# RUN: %clang_host -g -O0 %S/Inputs/sigchld.c -o %t.out
+# RUN: %clang_host -g -O0 %S/Inputs/cross_platform.c -o %t.out
 # RUN: %lldb %t.out -b -s %s 2>&1 | FileCheck %s
 
 list
@@ -13,10 +11,7 @@ r
 # CHECK: int main()
 
 list
-# CHECK: if (child_pid == 0)
-
-list
-# CHECK: printf("signo = %d\n", SIGCHLD);
+# CHECK: bubbleSort(arr, n);
 
 list
 # CHECK: return 0;

@DavidSpickett
Copy link
Collaborator

Seems fine, my only question is does the source actually need to be doing this much?

Or in other words: the example should be as complex as it needs to be to show the bug. If that means just calling the same do-nothing function over and over to create more lines, that would be preferable.

(but I see that you chose something generic that will compile everywhere, thank you for that and that aspect is spot on)

@hapeeeeee hapeeeeee force-pushed the list-test-case-for-windows branch from b4dadb1 to 30318b2 Compare May 14, 2025 13:05
@hapeeeeee hapeeeeee force-pushed the list-test-case-for-windows branch from 30318b2 to d1b2957 Compare May 14, 2025 13:07
@hapeeeeee
Copy link
Contributor Author

Seems fine, my only question is does the source actually need to be doing this much?

Or in other words: the example should be as complex as it needs to be to show the bug. If that means just calling the same do-nothing function over and over to create more lines, that would be preferable.

I have removed unnecessary code to ensure that the file used in the test case is as simple as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants