Unverified 提交 e3ab41fe authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo 提交者: GitHub

Node: Add new worker.on('subprocessclose') to fix Node tests (#1307)

上级 82017d1d
# Changelog
### NEXT
- Node: Add new `worker.on('subprocessclose')` event ([PR #1307](https://github.com/versatica/mediasoup/pull/1307)).
### 3.13.15
- Add worker prebuild binary for Linux kernel 6 ([PR #1300](https://github.com/versatica/mediasoup/pull/1300)).
......
......@@ -228,15 +228,13 @@ export class Channel extends EnhancedEventEmitter {
this.#producerSocket.removeAllListeners('error');
this.#producerSocket.on('error', () => {});
// Destroy the socket after a while to allow pending incoming messages.
setTimeout(() => {
try {
this.#producerSocket.destroy();
} catch (error) {}
try {
this.#consumerSocket.destroy();
} catch (error) {}
}, 200);
// Destroy the sockets.
try {
this.#producerSocket.destroy();
} catch (error) {}
try {
this.#consumerSocket.destroy();
} catch (error) {}
}
/**
......
......@@ -200,6 +200,7 @@ export type WorkerDump = {
export type WorkerEvents = {
died: [Error];
subprocessclose: [];
listenererror: [string, Error];
// Private events.
'@success': [];
......@@ -244,7 +245,7 @@ export class Worker<
WorkerAppData extends AppData = AppData,
> extends EnhancedEventEmitter<WorkerEvents> {
// mediasoup-worker child process.
#child?: ChildProcess;
#child: ChildProcess;
// Worker process PID.
readonly #pid: number;
......@@ -258,6 +259,9 @@ export class Worker<
// Died dlag.
#died = false;
// Worker subprocess closed flag.
#subprocessClosed = false;
// Custom app data.
#appData: WorkerAppData;
......@@ -389,7 +393,10 @@ export class Worker<
});
this.#child.on('exit', (code, signal) => {
this.#child = undefined;
// If killed by ourselves, do nothing.
if (this.#child.killed) {
return;
}
if (!spawnDone) {
spawnDone = true;
......@@ -431,7 +438,10 @@ export class Worker<
});
this.#child.on('error', error => {
this.#child = undefined;
// If killed by ourselves, do nothing.
if (this.#child.killed) {
return;
}
if (!spawnDone) {
spawnDone = true;
......@@ -455,6 +465,19 @@ export class Worker<
}
});
this.#child.on('close', (code, signal) => {
logger.debug(
'worker subprocess closed [pid:%s, code:%s, signal:%s]',
this.#pid,
code,
signal,
);
this.#subprocessClosed = true;
this.safeEmit('subprocessclose');
});
// Be ready for 3rd party worker libraries logging to stdout.
this.#child.stdout!.on('data', buffer => {
for (const line of buffer.toString('utf8').split('\n')) {
......@@ -495,6 +518,13 @@ export class Worker<
return this.#died;
}
/**
* Whether the Worker subprocess is closed.
*/
get subprocessClosed(): boolean {
return this.#subprocessClosed;
}
/**
* App custom data.
*/
......@@ -545,15 +575,7 @@ export class Worker<
this.#closed = true;
// Kill the worker process.
if (this.#child) {
// Remove event listeners but leave a fake 'error' hander to avoid
// propagation.
this.#child.removeAllListeners('exit');
this.#child.removeAllListeners('error');
this.#child.on('error', () => {});
this.#child.kill('SIGTERM');
this.#child = undefined;
}
this.#child.kill('SIGTERM');
// Close the Channel instance.
this.#channel.close();
......
......@@ -27,8 +27,14 @@ beforeEach(async () => {
ctx.router = await ctx.worker.createRouter({ mediaCodecs: ctx.mediaCodecs });
});
afterEach(() => {
afterEach(async () => {
ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
});
test('router.createActiveSpeakerObserver() succeeds', async () => {
......
......@@ -27,8 +27,14 @@ beforeEach(async () => {
ctx.router = await ctx.worker.createRouter({ mediaCodecs: ctx.mediaCodecs });
});
afterEach(() => {
afterEach(async () => {
ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
});
test('router.createAudioLevelObserver() succeeds', async () => {
......
......@@ -241,8 +241,14 @@ beforeEach(async () => {
);
});
afterEach(() => {
afterEach(async () => {
ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
});
test('transport.consume() succeeds', async () => {
......@@ -330,7 +336,7 @@ test('transport.consume() succeeds', async () => {
).toBe(true);
// Pause videoProducer.
ctx.videoProducer!.pause();
await ctx.videoProducer!.pause();
const videoConsumer = await ctx.webRtcTransport2!.consume({
producerId: ctx.videoProducer!.id,
......@@ -987,22 +993,25 @@ test('Consumer emits "producerpause" and "producerresume"', async () => {
rtpCapabilities: ctx.consumerDeviceCapabilities,
});
await new Promise<void>(resolve => {
// eslint-disable-next-line no-async-promise-executor
await new Promise<void>(async resolve => {
audioConsumer.on('producerpause', resolve);
ctx.audioProducer!.pause().catch(() => {});
// Let's await for pause() to resolve to avoid aborted channel requests
// due to worker closure.
await ctx.audioProducer!.pause();
});
expect(audioConsumer.paused).toBe(false);
expect(audioConsumer.producerPaused).toBe(true);
await new Promise<void>(resolve => {
// eslint-disable-next-line no-async-promise-executor
await new Promise<void>(async resolve => {
audioConsumer.on('producerresume', resolve);
// Let's catch rejection since the test will complete before we get the
// response to this channel request, and if we don't handle that rejection
// it will make Jest fail any other random test.
ctx.audioProducer!.resume().catch(() => {});
// Let's await for resume() to resolve to avoid aborted channel requests
// due to worker closure.
await ctx.audioProducer!.resume();
});
expect(audioConsumer.paused).toBe(false);
......
......@@ -40,8 +40,14 @@ beforeEach(async () => {
);
});
afterEach(() => {
afterEach(async () => {
ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
});
test('transport.consumeData() succeeds', async () => {
......
......@@ -44,8 +44,14 @@ beforeEach(async () => {
});
});
afterEach(() => {
afterEach(async () => {
ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
});
test('webRtcTransport1.produceData() succeeds', async () => {
......
......@@ -12,8 +12,14 @@ beforeEach(async () => {
ctx.router = await ctx.worker.createRouter();
});
afterEach(() => {
afterEach(async () => {
ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
});
test('router.createDirectTransport() succeeds', async () => {
......@@ -138,7 +144,7 @@ test('dataProducer.send() succeeds', async () => {
);
});
sendNextMessage();
await sendNextMessage();
async function sendNextMessage(): Promise<void> {
const id = ++numSentMessages;
......
......@@ -195,9 +195,21 @@ beforeEach(async () => {
);
});
afterEach(() => {
afterEach(async () => {
ctx.worker1?.close();
ctx.worker2?.close();
if (ctx.worker1?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker1?.on('subprocessclose', resolve),
);
}
if (ctx.worker2?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker2?.on('subprocessclose', resolve),
);
}
});
test('router.pipeToRouter() succeeds with audio', async () => {
......
......@@ -49,8 +49,14 @@ beforeEach(async () => {
ctx.router = await ctx.worker.createRouter({ mediaCodecs: ctx.mediaCodecs });
});
afterEach(() => {
afterEach(async () => {
ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
});
test('router.createPlainTransport() succeeds', async () => {
......
......@@ -144,8 +144,14 @@ beforeEach(async () => {
});
});
afterEach(() => {
afterEach(async () => {
ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
});
test('webRtcTransport1.produce() succeeds', async () => {
......
......@@ -42,8 +42,14 @@ beforeEach(async () => {
ctx.worker = await mediasoup.createWorker();
});
afterEach(() => {
afterEach(async () => {
ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
});
test('worker.createRouter() succeeds', async () => {
......
......@@ -13,8 +13,14 @@ beforeEach(async () => {
ctx.worker = await mediasoup.createWorker();
});
afterEach(() => {
afterEach(async () => {
ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
});
test('worker.createWebRtcServer() succeeds', async () => {
......
......@@ -54,8 +54,14 @@ beforeEach(async () => {
ctx.router = await ctx.worker.createRouter({ mediaCodecs: ctx.mediaCodecs });
});
afterEach(() => {
afterEach(async () => {
ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
});
test('router.createWebRtcTransport() succeeds', async () => {
......
......@@ -48,6 +48,8 @@ test('createWorker() succeeds', async () => {
worker1.close();
await new Promise<void>(resolve => worker1.on('subprocessclose', resolve));
expect(worker1.closed).toBe(true);
expect(worker1.died).toBe(false);
......@@ -70,6 +72,8 @@ test('createWorker() succeeds', async () => {
worker2.close();
await new Promise<void>(resolve => worker2.on('subprocessclose', resolve));
expect(worker2.closed).toBe(true);
expect(worker2.died).toBe(false);
}, 2000);
......@@ -111,6 +115,8 @@ test('worker.updateSettings() succeeds', async () => {
).resolves.toBeUndefined();
worker.close();
await new Promise<void>(resolve => worker.on('subprocessclose', resolve));
}, 2000);
test('worker.updateSettings() with wrong settings rejects with TypeError', async () => {
......@@ -122,6 +128,8 @@ test('worker.updateSettings() with wrong settings rejects with TypeError', async
);
worker.close();
await new Promise<void>(resolve => worker.on('subprocessclose', resolve));
}, 2000);
test('worker.updateSettings() rejects with InvalidStateError if closed', async () => {
......@@ -129,6 +137,8 @@ test('worker.updateSettings() rejects with InvalidStateError if closed', async (
worker.close();
await new Promise<void>(resolve => worker.on('subprocessclose', resolve));
await expect(worker.updateSettings({ logLevel: 'error' })).rejects.toThrow(
InvalidStateError,
);
......@@ -155,6 +165,8 @@ test('worker.dump() rejects with InvalidStateError if closed', async () => {
worker.close();
await new Promise<void>(resolve => worker.on('subprocessclose', resolve));
await expect(worker.dump()).rejects.toThrow(InvalidStateError);
}, 2000);
......@@ -164,6 +176,8 @@ test('worker.getResourceUsage() succeeds', async () => {
await expect(worker.getResourceUsage()).resolves.toMatchObject({});
worker.close();
await new Promise<void>(resolve => worker.on('subprocessclose', resolve));
}, 2000);
test('worker.close() succeeds', async () => {
......@@ -173,6 +187,8 @@ test('worker.close() succeeds', async () => {
worker.observer.once('close', onObserverClose);
worker.close();
await new Promise<void>(resolve => worker.on('subprocessclose', resolve));
expect(onObserverClose).toHaveBeenCalledTimes(1);
expect(worker.closed).toBe(true);
expect(worker.died).toBe(false);
......@@ -209,6 +225,10 @@ test('Worker emits "died" if worker process died unexpectedly', async () => {
process.kill(worker1.pid, 'SIGINT');
});
if (!worker1.subprocessClosed) {
await new Promise<void>(resolve => worker1.on('subprocessclose', resolve));
}
expect(onDied).toHaveBeenCalledTimes(1);
expect(onObserverClose).toHaveBeenCalledTimes(1);
expect(worker1.closed).toBe(true);
......@@ -241,6 +261,10 @@ test('Worker emits "died" if worker process died unexpectedly', async () => {
process.kill(worker2.pid, 'SIGTERM');
});
if (!worker2.subprocessClosed) {
await new Promise<void>(resolve => worker2.on('subprocessclose', resolve));
}
expect(onDied).toHaveBeenCalledTimes(1);
expect(onObserverClose).toHaveBeenCalledTimes(1);
expect(worker2.closed).toBe(true);
......@@ -273,6 +297,10 @@ test('Worker emits "died" if worker process died unexpectedly', async () => {
process.kill(worker3.pid, 'SIGKILL');
});
if (!worker3.subprocessClosed) {
await new Promise<void>(resolve => worker3.on('subprocessclose', resolve));
}
expect(onDied).toHaveBeenCalledTimes(1);
expect(onObserverClose).toHaveBeenCalledTimes(1);
expect(worker3.closed).toBe(true);
......@@ -298,7 +326,7 @@ if (os.platform() !== 'win32') {
expect(worker.closed).toBe(false);
worker.close();
resolve();
worker.on('subprocessclose', resolve);
}, 2000);
});
}, 3000);
......
......@@ -103,8 +103,14 @@ beforeEach(async () => {
});
});
afterEach(() => {
afterEach(async () => {
ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
});
test('produce() and consume() succeed', async () => {
......
......@@ -99,10 +99,16 @@ afterEach(async () => {
ctx.sctpSocket?.end();
ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
// NOTE: For some reason we have to wait a bit for the SCTP stuff to release
// internal things, otherwise Jest reports open handles. We don't care much
// honestly.
await new Promise(resolve => setTimeout(resolve, 2000));
await new Promise(resolve => setTimeout(resolve, 1000));
});
test('ordered DataProducer delivers all SCTP messages to the DataConsumer', async () => {
......
......@@ -296,7 +296,7 @@ function installInvoke() {
// Install pip invoke into custom location, so we don't depend on system-wide
// installation.
executeCmd(
`"${PYTHON}" -m pip install --upgrade --no-user --target="${PIP_INVOKE_DIR}" invoke`,
`"${PYTHON}" -m pip install --upgrade --no-user --target "${PIP_INVOKE_DIR}" invoke`,
/* exitOnError */ true,
);
}
......@@ -420,7 +420,7 @@ function flatcWorker() {
function testNode() {
logInfo('testNode()');
executeCmd(`jest --detectOpenHandles ${args}`);
executeCmd(`jest --silent false --detectOpenHandles ${args}`);
}
function testWorker() {
......
......@@ -47,75 +47,75 @@ invoke:
ifeq ($(wildcard $(PIP_INVOKE_DIR)),)
# Install pip invoke into custom location, so we don't depend on system-wide
# installation.
$(PYTHON) -m pip install --upgrade --no-user --target="$(PIP_INVOKE_DIR)" invoke
"$(PYTHON)" -m pip install --upgrade --no-user --target "$(PIP_INVOKE_DIR)" invoke
endif
meson-ninja: invoke
$(PYTHON) -m invoke meson-ninja
"$(PYTHON)" -m invoke meson-ninja
setup: invoke
$(PYTHON) -m invoke setup
"$(PYTHON)" -m invoke setup
clean: invoke
$(PYTHON) -m invoke clean
"$(PYTHON)" -m invoke clean
clean-build: invoke
$(PYTHON) -m invoke clean-build
"$(PYTHON)" -m invoke clean-build
clean-pip: invoke
$(PYTHON) -m invoke clean-pip
"$(PYTHON)" -m invoke clean-pip
clean-subprojects: invoke
$(PYTHON) -m invoke clean-subprojects
"$(PYTHON)" -m invoke clean-subprojects
clean-all: invoke
$(PYTHON) -m invoke clean-all
"$(PYTHON)" -m invoke clean-all
# It requires the SUBPROJECT environment variable.
update-wrap-file: invoke
$(PYTHON) -m invoke subprojects $(SUBPROJECT)
"$(PYTHON)" -m invoke subprojects $(SUBPROJECT)
mediasoup-worker: invoke
$(PYTHON) -m invoke mediasoup-worker
"$(PYTHON)" -m invoke mediasoup-worker
libmediasoup-worker: invoke
$(PYTHON) -m invoke libmediasoup-worker
"$(PYTHON)" -m invoke libmediasoup-worker
flatc: invoke
$(PYTHON) -m invoke flatc
"$(PYTHON)" -m invoke flatc
xcode: invoke
$(PYTHON) -m invoke xcode
"$(PYTHON)" -m invoke xcode
lint: invoke
$(PYTHON) -m invoke lint
"$(PYTHON)" -m invoke lint
format: invoke
$(PYTHON) -m invoke format
"$(PYTHON)" -m invoke format
test: invoke
$(PYTHON) -m invoke test
"$(PYTHON)" -m invoke test
test-asan: invoke
$(PYTHON) -m invoke test-asan
"$(PYTHON)" -m invoke test-asan
tidy: invoke
$(PYTHON) -m invoke tidy
"$(PYTHON)" -m invoke tidy
fuzzer: invoke
$(PYTHON) -m invoke fuzzer
"$(PYTHON)" -m invoke fuzzer
fuzzer-run-all: invoke
$(PYTHON) -m invoke fuzzer-run-all
"$(PYTHON)" -m invoke fuzzer-run-all
docker: invoke
$(PYTHON) -m invoke docker
"$(PYTHON)" -m invoke docker
docker-run: invoke
$(PYTHON) -m invoke docker-run
"$(PYTHON)" -m invoke docker-run
docker-alpine: invoke
$(PYTHON) -m invoke docker-alpine
"$(PYTHON)" -m invoke docker-alpine
docker-alpine-run: invoke
$(PYTHON) -m invoke docker-alpine-run
"$(PYTHON)" -m invoke docker-alpine-run
......@@ -107,14 +107,14 @@ def meson_ninja(ctx):
# fallback to command without `--system` if the first one fails.
try:
ctx.run(
f'"{PYTHON}" -m pip install --system --upgrade --no-user --target="{PIP_MESON_NINJA_DIR}" pip setuptools',
f'"{PYTHON}" -m pip install --system --upgrade --no-user --target "{PIP_MESON_NINJA_DIR}" pip setuptools',
echo=True,
hide=True,
shell=SHELL
);
except:
ctx.run(
f'"{PYTHON}" -m pip install --upgrade --no-user --target="{PIP_MESON_NINJA_DIR}" pip setuptools',
f'"{PYTHON}" -m pip install --upgrade --no-user --target "{PIP_MESON_NINJA_DIR}" pip setuptools',
echo=True,
pty=PTY_SUPPORTED,
shell=SHELL
......@@ -127,7 +127,7 @@ def meson_ninja(ctx):
# Install meson and ninja using pip into our custom location, so we don't
# depend on system-wide installation.
ctx.run(
f'"{PYTHON}" -m pip install --upgrade --no-user --target="{PIP_MESON_NINJA_DIR}" {pip_build_binaries} meson=={MESON_VERSION} ninja=={NINJA_VERSION}',
f'"{PYTHON}" -m pip install --upgrade --no-user --target "{PIP_MESON_NINJA_DIR}" {pip_build_binaries} meson=={MESON_VERSION} ninja=={NINJA_VERSION}',
echo=True,
pty=PTY_SUPPORTED,
shell=SHELL
......@@ -140,7 +140,7 @@ def setup(ctx):
Run meson setup
"""
if MEDIASOUP_BUILDTYPE == 'Release':
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" setup --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype release -Db_ndebug=true {MESON_ARGS} "{BUILD_DIR}"',
echo=True,
......@@ -148,7 +148,7 @@ def setup(ctx):
shell=SHELL
);
elif MEDIASOUP_BUILDTYPE == 'Debug':
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" setup --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype debug {MESON_ARGS} "{BUILD_DIR}"',
echo=True,
......@@ -156,7 +156,7 @@ def setup(ctx):
shell=SHELL
);
else:
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" setup --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype {MEDIASOUP_BUILDTYPE} -Db_ndebug=if-release {MESON_ARGS} "{BUILD_DIR}"',
echo=True,
......@@ -208,7 +208,7 @@ def clean_subprojects(ctx):
"""
Clean meson subprojects
"""
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" subprojects purge --include-cache --confirm',
echo=True,
......@@ -222,7 +222,7 @@ def clean_all(ctx):
"""
Clean meson subprojects and all installed/built artificats
"""
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
try:
ctx.run(
f'"{MESON}" subprojects purge --include-cache --confirm',
......@@ -244,7 +244,7 @@ def update_wrap_file(ctx, subproject):
"""
Update the wrap file of a subproject
"""
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" subprojects update --reset {subproject}',
echo=True,
......@@ -258,7 +258,7 @@ def flatc(ctx):
"""
Compile FlatBuffers FBS files
"""
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" compile -C "{BUILD_DIR}" flatbuffers-generator',
echo=True,
......@@ -276,14 +276,14 @@ def mediasoup_worker(ctx):
print('skipping mediasoup-worker compilation due to the existence of the MEDIASOUP_WORKER_BIN environment variable');
return;
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker',
echo=True,
pty=PTY_SUPPORTED,
shell=SHELL
);
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker',
echo=True,
......@@ -297,14 +297,14 @@ def libmediasoup_worker(ctx):
"""
Compile libmediasoup-worker library
"""
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} libmediasoup-worker',
echo=True,
pty=PTY_SUPPORTED,
shell=SHELL
);
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags libmediasoup-worker',
echo=True,
......@@ -318,7 +318,7 @@ def xcode(ctx):
"""
Setup Xcode project
"""
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" setup --buildtype {MEDIASOUP_BUILDTYPE.lower()} --backend xcode "{MEDIASOUP_OUT_DIR}/xcode"',
echo=True,
......@@ -332,7 +332,7 @@ def lint(ctx):
"""
Lint source code
"""
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{NPM}" run lint --prefix scripts/',
echo=True,
......@@ -349,7 +349,7 @@ def lint(ctx):
shell=SHELL
);
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{PYTHON}" -m pylint tasks.py',
echo=True,
......@@ -363,7 +363,7 @@ def format(ctx):
"""
Format source code according to lint rules
"""
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{NPM}" run format --prefix scripts/',
echo=True,
......@@ -377,14 +377,14 @@ def test(ctx):
"""
Run worker tests
"""
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test',
echo=True,
pty=PTY_SUPPORTED,
shell=SHELL
);
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test',
echo=True,
......@@ -395,7 +395,7 @@ def test(ctx):
mediasoup_worker_test = 'mediasoup-worker-test.exe' if os.name == 'nt' else 'mediasoup-worker-test';
mediasoup_test_tags = os.getenv('MEDIASOUP_TEST_TAGS') or '';
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{BUILD_DIR}/{mediasoup_worker_test}" --invisibles --colour-mode=ansi {mediasoup_test_tags}',
echo=True,
......@@ -409,14 +409,14 @@ def test_asan(ctx):
"""
Run worker test with Address Sanitizer
"""
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test-asan',
echo=True,
pty=PTY_SUPPORTED,
shell=SHELL
);
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test-asan',
echo=True,
......@@ -426,7 +426,7 @@ def test_asan(ctx):
mediasoup_test_tags = os.getenv('MEDIASOUP_TEST_TAGS') or '';
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'ASAN_OPTIONS=detect_leaks=1 "{BUILD_DIR}/mediasoup-worker-test-asan" --invisibles --use-colour=yes {mediasoup_test_tags}',
echo=True,
......@@ -442,7 +442,7 @@ def tidy(ctx):
"""
mediasoup_tidy_checks = os.getenv('MEDIASOUP_TIDY_CHECKS') or '';
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{PYTHON}" ./scripts/clang-tidy.py -clang-tidy-binary=./scripts/node_modules/.bin/clang-tidy -clang-apply-replacements-binary=./scripts/node_modules/.bin/clang-apply-replacements -header-filter="(Channel/**/*.hpp|DepLibSRTP.hpp|DepLibUV.hpp|DepLibWebRTC.hpp|DepOpenSSL.hpp|DepUsrSCTP.hpp|LogLevel.hpp|Logger.hpp|MediaSoupError.hpp|RTC/**/*.hpp|Settings.hpp|Utils.hpp|Worker.hpp|common.hpp|handles/**/*.hpp)" -p="{BUILD_DIR}" -j={NUM_CORES} -checks={mediasoup_tidy_checks} -quiet',
echo=True,
......@@ -456,14 +456,14 @@ def fuzzer(ctx):
"""
Build the mediasoup-worker-fuzzer binary (which uses libFuzzer)
"""
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-fuzzer',
echo=True,
pty=PTY_SUPPORTED,
shell=SHELL
);
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-fuzzer',
echo=True,
......@@ -477,7 +477,7 @@ def fuzzer_run_all(ctx):
"""
Run all fuzzer cases
"""
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'LSAN_OPTIONS=verbosity=1:log_threads=1 "{BUILD_DIR}/mediasoup-worker-fuzzer" -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus',
echo=True,
......@@ -492,7 +492,7 @@ def docker(ctx):
Build a Linux Ubuntu Docker image with fuzzer capable clang++
"""
if os.getenv('DOCKER_NO_CACHE') == 'true':
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{DOCKER}" build -f Dockerfile --no-cache --tag mediasoup/docker:latest .',
echo=True,
......@@ -500,7 +500,7 @@ def docker(ctx):
shell=SHELL
);
else:
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{DOCKER}" build -f Dockerfile --tag mediasoup/docker:latest .',
echo=True,
......@@ -514,7 +514,7 @@ def docker_run(ctx):
"""
Run a container of the Ubuntu Docker image created in the docker task
"""
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{DOCKER}" run --name=mediasoupDocker -it --rm --privileged --cap-add SYS_PTRACE -v "{WORKER_DIR}/../:/mediasoup" mediasoup/docker:latest',
echo=True,
......@@ -529,7 +529,7 @@ def docker_alpine(ctx):
Build a Linux Alpine Docker image
"""
if os.getenv('DOCKER_NO_CACHE') == 'true':
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{DOCKER}" build -f Dockerfile.alpine --no-cache --tag mediasoup/docker-alpine:latest .',
echo=True,
......@@ -537,7 +537,7 @@ def docker_alpine(ctx):
shell=SHELL
);
else:
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{DOCKER}" build -f Dockerfile.alpine --tag mediasoup/docker-alpine:latest .',
echo=True,
......@@ -551,7 +551,7 @@ def docker_alpine_run(ctx):
"""
Run a container of the Alpine Docker image created in the docker_alpine task
"""
with ctx.cd(WORKER_DIR):
with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run(
f'"{DOCKER}" run --name=mediasoupDockerAlpine -it --rm --privileged --cap-add SYS_PTRACE -v "{WORKER_DIR}/../:/mediasoup" mediasoup/docker-alpine:latest',
echo=True,
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论