2
2
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
4
4
using System . Collections . Generic ;
5
+ using System . ComponentModel ;
5
6
using System . IO ;
6
7
using System . Linq ;
7
8
using System . Threading ;
@@ -185,35 +186,18 @@ public void TestMachineName()
185
186
Assert . NotNull ( _process . MachineName ) ;
186
187
}
187
188
188
- [ ActiveIssue ( 1896 ) ]
189
- [ Fact ]
190
- public void TestMainModule ( )
189
+ [ Fact , PlatformSpecific ( ~ PlatformID . OSX ) ]
190
+ public void TestMainModuleOnNonOSX ( )
191
191
{
192
- // Module support is not enabled on OSX
193
- if ( global ::Interop . IsOSX )
194
- {
195
- Assert . Null ( _process . MainModule ) ;
196
- Assert . Equal ( 0 , _process . Modules . Count ) ;
197
- return ;
198
- }
199
-
200
- // Ensure the process has loaded the modules.
201
- Assert . True ( SpinWait . SpinUntil ( ( ) =>
202
- {
203
- if ( _process . Modules . Count > 0 )
204
- return true ;
205
- _process . Refresh ( ) ;
206
- return false ;
207
- } , WaitInMS ) ) ;
208
-
209
- // Get MainModule property from a Process object
210
- ProcessModule mainModule = _process . MainModule ;
211
- Assert . NotNull ( mainModule ) ;
212
- Assert . Equal ( CoreRunName , Path . GetFileNameWithoutExtension ( mainModule . ModuleName ) ) ;
192
+ string fileName = "corerun" ;
193
+ if ( global ::Interop . IsWindows )
194
+ fileName = "CoreRun.exe" ;
213
195
214
- // Check that the mainModule is present in the modules list.
215
- IEnumerable < string > processModuleNames = _process . Modules . Cast < ProcessModule > ( ) . Select ( p => Path . GetFileNameWithoutExtension ( p . ModuleName ) ) ;
216
- Assert . Contains ( CoreRunName , processModuleNames ) ;
196
+ Process p = Process . GetCurrentProcess ( ) ;
197
+ Assert . True ( p . Modules . Count > 0 ) ;
198
+ Assert . Equal ( fileName , p . MainModule . ModuleName ) ;
199
+ Assert . EndsWith ( fileName , p . MainModule . FileName ) ;
200
+ Assert . Equal ( string . Format ( "System.Diagnostics.ProcessModule ({0})" , fileName ) , p . MainModule . ToString ( ) ) ;
217
201
}
218
202
219
203
[ Fact ]
@@ -377,7 +361,6 @@ public void TestProcessorTime()
377
361
Assert . InRange ( processorTimeAtHalfSpin , processorTimeBeforeSpin , Process . GetCurrentProcess ( ) . TotalProcessorTime . TotalSeconds ) ;
378
362
}
379
363
380
- [ ActiveIssue ( 2474 ) ]
381
364
[ Fact ]
382
365
public void TestProcessStartTime ( )
383
366
{
@@ -391,8 +374,10 @@ public void TestProcessStartTime()
391
374
// Thus, because there are HZ timer interrupts in a second, there are HZ jiffies in a second. Hence 1\HZ, will
392
375
// be the resolution of system timer. The lowest value of HZ on unix is 100, hence the timer resolution is 10 ms.
393
376
// Allowing for error in 10 ms.
394
- long beforeTicks = timeBeforeCreatingProcess . Ticks - new TimeSpan ( 0 , 0 , 0 , 0 , 10 ) . Ticks ;
395
- Assert . InRange ( p . StartTime . ToUniversalTime ( ) . Ticks , beforeTicks , DateTime . UtcNow . Ticks ) ;
377
+ long tenMSTicks = new TimeSpan ( 0 , 0 , 0 , 0 , 10 ) . Ticks ;
378
+ long beforeTicks = timeBeforeCreatingProcess . Ticks - tenMSTicks ;
379
+ long afterTicks = DateTime . UtcNow . Ticks + tenMSTicks ;
380
+ Assert . InRange ( p . StartTime . ToUniversalTime ( ) . Ticks , beforeTicks , afterTicks ) ;
396
381
}
397
382
finally
398
383
{
0 commit comments