@@ -79,7 +79,7 @@ public void SetAndCheckBasePriority(ProcessPriorityClass exPriorityClass, int pr
79
79
Assert . Equal ( priority , _process . BasePriority ) ;
80
80
}
81
81
82
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
82
+ [ Fact ]
83
83
public void Process_BasePriority ( )
84
84
{
85
85
ProcessPriorityClass originalPriority = _process . PriorityClass ;
@@ -119,7 +119,7 @@ public void StartAndKillProcessWithDelay(Process p)
119
119
Assert . True ( p . WaitForExit ( WaitInMS ) ) ;
120
120
}
121
121
122
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
122
+ [ Fact ]
123
123
public void Process_EnableRaiseEvents ( )
124
124
{
125
125
{
@@ -156,7 +156,7 @@ public void Process_EnableRaiseEvents()
156
156
}
157
157
}
158
158
159
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
159
+ [ Fact ]
160
160
public void Process_ExitCode ( )
161
161
{
162
162
{
@@ -261,11 +261,17 @@ public void Process_MainModule()
261
261
}
262
262
}
263
263
264
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
264
+ [ Fact ]
265
265
public void Process_MaxWorkingSet ( )
266
266
{
267
- IntPtr min , max ;
268
- uint flags ;
267
+ using ( Process p = Process . GetCurrentProcess ( ) )
268
+ {
269
+ Assert . True ( ( long ) p . MaxWorkingSet > 0 ) ;
270
+ Assert . True ( ( long ) p . MinWorkingSet >= 0 ) ;
271
+ }
272
+
273
+ if ( global ::Interop . IsOSX )
274
+ return ; // doesn't support getting/setting working set for other processes
269
275
270
276
long curValue = ( long ) _process . MaxWorkingSet ;
271
277
Assert . True ( curValue >= 0 ) ;
@@ -275,6 +281,9 @@ public void Process_MaxWorkingSet()
275
281
try
276
282
{
277
283
_process . MaxWorkingSet = ( IntPtr ) ( ( int ) curValue + 1024 ) ;
284
+
285
+ IntPtr min , max ;
286
+ uint flags ;
278
287
Interop . GetProcessWorkingSetSizeEx ( _process . SafeHandle , out min , out max , out flags ) ;
279
288
curValue = ( int ) max ;
280
289
_process . Refresh ( ) ;
@@ -287,9 +296,18 @@ public void Process_MaxWorkingSet()
287
296
}
288
297
}
289
298
290
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
299
+ [ Fact ]
291
300
public void Process_MinWorkingSet ( )
292
301
{
302
+ using ( Process p = Process . GetCurrentProcess ( ) )
303
+ {
304
+ Assert . True ( ( long ) p . MaxWorkingSet > 0 ) ;
305
+ Assert . True ( ( long ) p . MinWorkingSet >= 0 ) ;
306
+ }
307
+
308
+ if ( global ::Interop . IsOSX )
309
+ return ; // doesn't support getting/setting working set for other processes
310
+
293
311
long curValue = ( long ) _process . MinWorkingSet ;
294
312
Assert . True ( curValue >= 0 ) ;
295
313
@@ -341,57 +359,59 @@ private void AssertNonZeroWindowsZeroUnix(long value)
341
359
}
342
360
}
343
361
344
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
362
+ [ Fact ]
345
363
public void Process_NonpagedSystemMemorySize64 ( )
346
364
{
347
365
AssertNonZeroWindowsZeroUnix ( _process . NonpagedSystemMemorySize64 ) ;
348
366
}
349
367
350
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
368
+ [ Fact ]
351
369
public void Process_PagedMemorySize64 ( )
352
370
{
353
371
AssertNonZeroWindowsZeroUnix ( _process . PagedMemorySize64 ) ;
354
372
}
355
373
356
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
374
+ [ Fact ]
357
375
public void Process_PagedSystemMemorySize64 ( )
358
376
{
359
377
AssertNonZeroWindowsZeroUnix ( _process . PagedSystemMemorySize64 ) ;
360
378
}
361
379
362
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
380
+ [ Fact ]
363
381
public void Process_PeakPagedMemorySize64 ( )
364
382
{
365
383
AssertNonZeroWindowsZeroUnix ( _process . PeakPagedMemorySize64 ) ;
366
384
}
367
385
368
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
386
+ [ Fact ]
369
387
public void Process_PeakVirtualMemorySize64 ( )
370
388
{
371
389
AssertNonZeroWindowsZeroUnix ( _process . PeakVirtualMemorySize64 ) ;
372
390
}
373
391
374
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
392
+ [ Fact ]
375
393
public void Process_PeakWorkingSet64 ( )
376
394
{
377
395
AssertNonZeroWindowsZeroUnix ( _process . PeakWorkingSet64 ) ;
378
396
}
379
397
380
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
398
+ [ Fact ]
381
399
public void Process_PrivateMemorySize64 ( )
382
400
{
383
401
AssertNonZeroWindowsZeroUnix ( _process . PrivateMemorySize64 ) ;
384
402
}
385
403
386
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
387
- public void Process_PrivilegedProcessorTime ( )
404
+ [ Fact ]
405
+ [ ActiveIssue ( 2184 , PlatformID . OSX ) ]
406
+ public void Process_ProcessorTime ( )
388
407
{
389
408
Assert . True ( _process . UserProcessorTime . TotalSeconds >= 0 ) ;
390
409
Assert . True ( _process . PrivilegedProcessorTime . TotalSeconds >= 0 ) ;
391
410
Assert . True ( _process . TotalProcessorTime . TotalSeconds >= 0 ) ;
392
411
}
393
412
394
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
413
+ [ Fact ]
414
+ [ PlatformSpecific ( ~ PlatformID . OSX ) ] // getting/setting affinity not supported on OSX
395
415
public void Process_ProcessorAffinity ( )
396
416
{
397
417
IntPtr curProcessorAffinity = _process . ProcessorAffinity ;
@@ -449,7 +469,7 @@ public void Process_InvalidPriorityClass()
449
469
Assert . Throws < ArgumentException > ( ( ) => { p . PriorityClass = ProcessPriorityClass . Normal | ProcessPriorityClass . Idle ; } ) ;
450
470
}
451
471
452
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
472
+ [ Fact ]
453
473
public void ProcessProcessName ( )
454
474
{
455
475
Assert . Equal ( _process . ProcessName , CoreRunName , StringComparer . OrdinalIgnoreCase ) ;
@@ -462,7 +482,7 @@ public void ProcessProcessName()
462
482
[ DllImport ( "libc" ) ]
463
483
internal static extern int getpid ( ) ;
464
484
465
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
485
+ [ Fact ]
466
486
public void Process_GetCurrentProcess ( )
467
487
{
468
488
Process current = Process . GetCurrentProcess ( ) ;
@@ -476,7 +496,7 @@ public void Process_GetCurrentProcess()
476
496
Assert . Equal ( Process . GetProcessById ( currentProcessId ) . ProcessName , Process . GetCurrentProcess ( ) . ProcessName ) ;
477
497
}
478
498
479
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
499
+ [ Fact ]
480
500
public void Process_GetProcesses ( )
481
501
{
482
502
// Get all the processes running on the machine.
@@ -494,7 +514,7 @@ public void Process_GetProcesses()
494
514
Assert . True ( foundCurrentProcess , "Process_GetProcesses002 failed" ) ;
495
515
}
496
516
497
- [ Fact , ActiveIssue ( 1538 , PlatformID . OSX ) ]
517
+ [ Fact ]
498
518
public void Process_GetProcessesByName ( )
499
519
{
500
520
// Get the current process using its name
@@ -760,5 +780,25 @@ public void Process_IPC()
760
780
}
761
781
}
762
782
783
+ [ Fact ]
784
+ public void ThreadCount ( )
785
+ {
786
+ Assert . True ( _process . Threads . Count > 0 ) ;
787
+ using ( Process p = Process . GetCurrentProcess ( ) )
788
+ {
789
+ Assert . True ( p . Threads . Count > 0 ) ;
790
+ }
791
+ }
792
+
793
+ // [Fact] // uncomment for diagnostic purposes to list processes to console
794
+ public void ConsoleWriteLineProcesses ( )
795
+ {
796
+ foreach ( var p in Process . GetProcesses ( ) . OrderBy ( p => p . Id ) )
797
+ {
798
+ Console . WriteLine ( "{0} : \" {1}\" (Threads: {2})" , p . Id , p . ProcessName , p . Threads . Count ) ;
799
+ p . Dispose ( ) ;
800
+ }
801
+ }
802
+
763
803
}
764
804
}
0 commit comments