-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[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
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-lldb Author: Zax (hapeeeeee) ChangesAs @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:
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;
|
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) |
b4dadb1
to
30318b2
Compare
30318b2
to
d1b2957
Compare
I have removed unnecessary code to ensure that the file used in the test case is as simple as possible. |
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.