Skip to content

Commit 546b0f9

Browse files
[tests] add a smoke test for System.IO.Directory (#10331)
Context: #10330 The problem fixed in #10330 makes me think we are missing a test. And indeed, this crashed on CoreCLR! 07-23 22:46:43.058 7510 7535 I NUnit : DirectoryTest 07-23 22:46:43.058 7510 7535 I NUnit : GetFiles 07-23 22:46:43.061 7510 7535 D monodroid-assembly: [precompiled] clr_pinvoke_override ("libSystem.Native", "SystemNative_Stat") 07-23 22:46:43.062 7510 7535 D monodroid: [precompiled] p/invoke found 07-23 22:46:43.070 7510 7534 I droid.NET_Test: Explicit concurrent copying GC freed 45(32KB) AllocSpace objects, 0(0B) LOS objects, 57% free, 1148KB/2684KB, paused 1.838ms total 7.423ms 07-23 22:46:43.072 7510 7535 D monodroid-assembly: [precompiled] clr_pinvoke_override ("libSystem.Native", "SystemNative_OpenDir") 07-23 22:46:43.072 7510 7535 D monodroid: [precompiled] p/invoke found 07-23 22:46:43.072 7510 7535 D monodroid-assembly: [precompiled] clr_pinvoke_override ("libSystem.Native", "SystemNative_ReadDir") 07-23 22:46:43.072 7510 7535 D monodroid-assembly: Symbol 'SystemNative_ReadDir' in library 'libSystem.Native' not found in the generated tables, falling back to slow path 07-23 22:46:43.072 7510 7535 F monodroid-assembly: Missing pinvoke [email protected] 07-23 22:46:43.072 7510 7535 F monodroid-assembly: Abort at precompiled.cc:88:3 ('static void *xamarin::android::PinvokeOverride::monodroid_pinvoke_override(const char *, const char *)') --------- beginning of crash 07-23 22:46:43.073 7510 7535 F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 7535 (Instrumentation), pid 7510 (droid.NET_Tests) 07-23 22:46:43.094 7550 7550 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone 07-23 22:46:43.095 1870 1870 I /system/bin/tombstoned: received crash request for pid 7535 07-23 22:46:43.096 7550 7550 I crash_dump64: performing dump of process 7510 (target tid = 7535) 07-23 22:46:43.099 7550 7550 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 07-23 22:46:43.099 7550 7550 F DEBUG : Build fingerprint: 'Android/sdk_phone_x86_64/generic_x86_64:10/QSR1.210820.001/7663313:userdebug/test-keys' 07-23 22:46:43.099 7550 7550 F DEBUG : Revision: '0' 07-23 22:46:43.099 7550 7550 F DEBUG : ABI: 'x86_64' 07-23 22:46:43.100 7550 7550 F DEBUG : Timestamp: 2025-07-23 22:46:43+0000 07-23 22:46:43.100 7550 7550 F DEBUG : pid: 7510, tid: 7535, name: Instrumentation >>> Mono.Android.NET_Tests <<< 07-23 22:46:43.100 7550 7550 F DEBUG : uid: 10119 07-23 22:46:43.100 7550 7550 F DEBUG : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr -------- 07-23 22:46:43.100 7550 7550 F DEBUG : Abort message: 'Missing pinvoke [email protected]' 07-23 22:46:43.100 7550 7550 F DEBUG : rax 0000000000000000 rbx 0000000000001d56 rcx 000078b597d263f8 rdx 0000000000000006 07-23 22:46:43.100 7550 7550 F DEBUG : r8 000078b50724aa40 r9 0000000000000000 r10 000078b4b9e158d0 r11 0000000000000246 07-23 22:46:43.100 7550 7550 F DEBUG : r12 000078b507358b00 r13 000078b4b9e159c0 r14 000078b4b9e15958 r15 0000000000001d6f 07-23 22:46:43.100 7550 7550 F DEBUG : rdi 0000000000001d56 rsi 0000000000001d6f 07-23 22:46:43.100 7550 7550 F DEBUG : rbp 000078b4b9e15a70 rsp 000078b4b9e158c8 rip 000078b597d263f8 07-23 22:46:43.263 7550 7550 F DEBUG : 07-23 22:46:43.263 7550 7550 F DEBUG : backtrace: 07-23 22:46:43.263 7550 7550 F DEBUG : #00 pc 00000000000943f8 /apex/com.android.runtime/lib64/bionic/libc.so (syscall+24) (BuildId: b5c6019a3b4ea61b5e9a2f56319b584e) 07-23 22:46:43.263 7550 7550 F DEBUG : #1 pc 0000000000097146 /apex/com.android.runtime/lib64/bionic/libc.so (abort+182) (BuildId: b5c6019a3b4ea61b5e9a2f56319b584e) 07-23 22:46:43.263 7550 7550 F DEBUG : #2 pc 00000000000c41c9 /data/app/Mono.Android.NET_Tests-3-1TDlT55wuyU7WHXRhzQQ==/split_config.x86_64.apk!libnet-android.release.so (offset 0x1850000) (xamarin::android::Helpers::abort_application(_LogCategories, char const*, bool, std::__ndk1::source_location)+425) (BuildId: f25730a1c837257e71f58c776b710328f9824f26) 07-23 22:46:43.263 7550 7550 F DEBUG : #3 pc 00000000000cee85 /data/app/Mono.Android.NET_Tests-3-1TDlT55wuyU7WHXRhzQQ==/split_config.x86_64.apk!libnet-android.release.so (offset 0x1850000) (xamarin::android::PinvokeOverride::monodroid_pinvoke_override(char const*, char const*)+8725) (BuildId: f25730a1c837257e71f58c776b710328f9824f26) 07-23 22:46:43.264 7550 7550 F DEBUG : #4 pc 00000000000cf191 /data/app/Mono.Android.NET_Tests-3-1TDlT55wuyU7WHXRhzQQ==/split_config.x86_64.apk!libnet-android.release.so (offset 0x1850000) (xamarin::android::Host::clr_pinvoke_override(char const*, char const*)+225) (BuildId: f25730a1c837257e71f58c776b710328f9824f26) 07-23 22:46:43.264 7550 7550 F DEBUG : #5 pc 00000000003f21f6 /data/app/Mono.Android.NET_Tests-3-1TDlT55wuyU7WHXRhzQQ==/split_config.x86_64.apk With the fix in place in #10330, it passes.
1 parent 26aefff commit 546b0f9

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
<Compile Include="System\ExceptionTest.cs" />
105105
<Compile Include="System\TimeZoneTest.cs" />
106106
<Compile Include="System.Drawing\TypeConverterTest.cs" />
107+
<Compile Include="System.IO\DirectoryTest.cs" />
107108
<Compile Include="System.IO\DriveInfoTest.cs" />
108109
<Compile Include="System.IO.Compression\GZipStreamTest.cs" />
109110
<Compile Include="System.Linq\LinqExpressionTest.cs" />
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.IO;
3+
4+
using NUnit.Framework;
5+
6+
namespace System.IOTests;
7+
8+
[TestFixture]
9+
public class DirectoryTest
10+
{
11+
[Test]
12+
public void GetFiles ()
13+
{
14+
var directory = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile);
15+
Assert.IsTrue (Directory.Exists (directory), "Directory does not exist: " + directory);
16+
17+
// Write a file
18+
File.WriteAllText (Path.Combine (directory, "testfile.txt"), "This is a test file.");
19+
20+
// Verify that GetFiles returns the file
21+
string [] files = Directory.GetFiles (directory);
22+
Assert.IsNotNull (files, "GetFiles returned null for directory: " + directory);
23+
Assert.IsTrue (files.Length > 0, "No files found in directory: " + directory);
24+
}
25+
}

0 commit comments

Comments
 (0)