"...composable_kernel_rocm.git" did not exist on "56c7203541460a3787a795fabede9ec294fcdbcd"
Unverified Commit c39e688c authored by chicm-ms's avatar chicm-ms Committed by GitHub
Browse files

Fix IPC unit test (#511)

* Fix IPC unit test

* updates
parent 26cef96c
......@@ -26,12 +26,14 @@ export namespace NNIErrorNames {
}
export class NNIError extends Error {
public cause!: Error | undefined;
constructor (name: string, message: string, err?: Error) {
super(message);
this.name = name;
if (err !== undefined) {
this.stack = err.stack;
}
this.cause = err;
}
}
......
......@@ -103,7 +103,7 @@ class IpcInterface {
try {
const data: Buffer = encodeCommand(commandType, content);
if (!this.outgoingStream.write(data)) {
this.logger.error('Commands jammed in buffer!');
this.logger.warning('Commands jammed in buffer!');
}
} catch (err) {
throw new NNIError('Dispatcher Error', `Dispatcher Error: ${err.message}`, err);
......
......@@ -25,6 +25,7 @@ import { Deferred } from 'ts-deferred';
import { cleanupUnitTest, prepareUnitTest } from '../../common/utils';
import * as CommandType from '../commands';
import { createDispatcherInterface, IpcInterface } from '../ipcInterface';
import { NNIError } from '../../common/errors';
let sentCommands: {[key: string]: string}[] = [];
const receivedCommands: {[key: string]: string}[] = [];
......@@ -105,8 +106,13 @@ describe('core/protocol', (): void => {
});
it('sendCommand() should throw on too long command', (): void => {
assert.equal((<Error>commandTooLong).name, 'RangeError');
assert.equal((<Error>commandTooLong).message, 'Command too long');
if (commandTooLong === undefined) {
assert.fail('Should throw error')
} else {
const err: Error | undefined = (<NNIError>commandTooLong).cause;
assert(err && err.name === 'RangeError');
assert(err && err.message === 'Command too long');
}
});
it('sendCommand() should throw on wrong command type', (): void => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment