singrdk/base/Kernel/Singularity.Stress/StressDirect.sg

94 lines
3.3 KiB
Plaintext
Raw Normal View History

2008-03-05 09:52:00 -05:00
///////////////////////////////////////////////////////////////////////////////
//
// Microsoft Research Singularity
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// File: StressDirect.sg
// Note: Kernel diagnostics (testing and debugging)
//
// (non-shipping extensions to kernel ABI, for testing and debugging)
using System.Threading;
using Microsoft.SingSharp;
using Microsoft.Singularity;
using Microsoft.Singularity.Channels;
using Microsoft.Singularity.Memory;
using Microsoft.Singularity.Stress.Contracts;
using Microsoft.Singularity.Directory;
using System.Runtime.CompilerServices;
using System;
using Microsoft.Singularity.V1.Services;
namespace Microsoft.Singularity.Stress
{
public class StressDirect
{
private static string[]! GetArgs(ArgList* in ExHeap exArgs, int count)
{
2008-11-17 18:29:00 -05:00
if (exArgs == null) {
2008-03-05 09:52:00 -05:00
return new string[count];
}
2008-11-17 18:29:00 -05:00
else {
2008-03-05 09:52:00 -05:00
expose(exArgs)
{
char[] in ExHeap exArg = exArgs->arg;
ArgList* in ExHeap next = exArgs->next;
string[]! args = GetArgs(next, count + 1);
args[count] = Bitter.ToString(exArg);
return args;
}
}
}
public static unsafe uint KPTest(SharedHeap.Allocation* sharedArgs, int i)
{
ArgList* in ExHeap exArgs = (ArgList* in ExHeap) sharedArgs;
string[]! args = GetArgs(exArgs, 0);
2008-11-17 18:29:00 -05:00
if (exArgs != null) delete exArgs;
2008-03-05 09:52:00 -05:00
return new KPTestKernel().Go(args, i);
2008-11-17 18:29:00 -05:00
//
// if (exArgs != null) delete exArgs;
// return 0;
//
// char[][]! in ExHeap exArgs = (char[][]! in ExHeap) sharedArgs;
// string[]! args = new string[exArgs.Length];
// for (int j = 0; j < args.Length; j++) {
//// SharedHeapService.Allocation* sharedArg = (SharedHeapService.Allocation*) (exArgs[j]);
// char[]! in ExHeap exArg = (char[]! in ExHeap) (exArgs[j]);
// args[j] = Bitter.ToString(exArg);
// delete exArg;
// }
// delete exArgs;
// return new KPTestKernel().Go(args, i);
//
// SharedHeapService.Allocation*[]! in ExHeap exArgs = (SharedHeapService.Allocation*[]! in ExHeap) sharedArgs;
// string[]! args = new string[exArgs.Length];
// for (int j = 0; j < args.Length; j++) {
// SharedHeapService.Allocation* sharedArg = (SharedHeapService.Allocation*) (exArgs[j]);
// char[]! in ExHeap exArg = (char[]! in ExHeap) (sharedArg);
// args[j] = Bitter.ToString(exArg);
//// delete exArg;
// }
// delete exArgs;
// return new KPTestKernel().Go(args, i);
//
2008-03-05 09:52:00 -05:00
}
}
class KPTestKernel : KPTestBase
{
public override uint Go(string[]! args, int i)
{
if (i >= ((!) args).Length) return 0x87654321;
string arg = args[i];
2008-11-17 18:29:00 -05:00
if (arg == "throwstop") {
2008-03-05 09:52:00 -05:00
throw new ProcessStopException("ProcessStopException");
}
2008-11-17 18:29:00 -05:00
else {
2008-03-05 09:52:00 -05:00
return base.Go(args, i);
}
}
}
}