Received: from outbound.soverin.net (outbound.soverin.net [185.233.34.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4976214B077 for ; Thu, 25 Apr 2024 15:44:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.34.146 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714059876; cv=none; b=amBEb+ehqG5vv2sLMa8nrHTI3RShgCYBWE/La2bDbYjvGZ5frVDewgPfIUDIFkvny0n/Updpe8c4PGfa1rrzAh/ZHM4xN75I5k9HRk7ak6T5EtM2sGQ7HVn+a/snQ6OxcoQ4qLhBo1e4EvC0RJFLxvLNJFcTSKrb2oHTNTXxvz4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714059876; c=relaxed/simple; bh=tCTB1ZStNoGoZ97S0nOtpmRjOTpC16uX2kAjLgzHbLQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FiuIb7sN0ybzov+rwnU9KAb1J69KUHxZsJN29by/fKrSj5VHYAASHR8x7yXTsitjgLcvCDL3LThuM+cxkj/CdXXQA2/OY3PqP6Kd/P0O6qVDgnqjqPw9iGq/9RNueYslzUD2pg62pJtWdhGE05swWfLQ8QzNjaeKMpcgYxZjOtM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=raymakers.nl; spf=pass smtp.mailfrom=raymakers.nl; dkim=pass (2048-bit key) header.d=raymakers.nl header.i=@raymakers.nl header.b=jitFSDLS; arc=none smtp.client-ip=185.233.34.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=raymakers.nl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raymakers.nl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raymakers.nl header.i=@raymakers.nl header.b="jitFSDLS" Received: from smtp.soverin.net (c04cst-smtp-sov01.int.sover.in [10.10.4.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by outbound.soverin.net (Postfix) with ESMTPS id 4VQKhg41pRz3n; Thu, 25 Apr 2024 15:36:35 +0000 (UTC) Received: from smtp.soverin.net (smtp.soverin.net [10.10.4.99]) by soverin.net (Postfix) with ESMTPSA id 4VQKhf6zNBz5n; Thu, 25 Apr 2024 15:36:34 +0000 (UTC) Authentication-Results: smtp.soverin.net; dkim=pass (2048-bit key; unprotected) header.d=raymakers.nl header.i=@raymakers.nl header.a=rsa-sha256 header.s=soverin1 header.b=jitFSDLS; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raymakers.nl; s=soverin1; t=1714059395; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x/HI9tGfyH0B6Xsi7qQfkEvMaXQoOr52cTfuIl7ugmY=; b=jitFSDLSusswEwnM9voW6KmkvfGYnvEadqo/PkxFyW1eiDTgEBsKB77m9pveRayKufFMR3 M6bYI4JA9oTzH71z66SCNAL4JknZaq9UOQxEEuynde6sBZPD05UmM68VL+dJKL65OhTPsb 6SpTy5Rx34bk3LBTGWay1lFaBNzCnlzN2PC9fprUd4WujiHidX4pQ/LWBN1XMLAiv0ZM2m iAOXikWdma3HvBMswwuvAopnCXXuM/X3ceG6hit3JtzW02YgVBvSblpDxeHwiut483eHsT rrOmcYsVZDWIqvKvQt/cgFgLcYri6Jiv4gUMhWvGBvC4ic04gPqQcFyR8dmkJA== From: Thijs Raymakers To: thomas@t-8ch.de Cc: kzak@redhat.com, util-linux@vger.kernel.org, Thijs Raymakers , Phil Auld Subject: [PATCH v11] coresched: Manage core scheduling cookies for tasks Date: Thu, 25 Apr 2024 17:36:26 +0200 Message-ID: <20240425153627.120762-1-thijs@raymakers.nl> In-Reply-To: <20240423111251.367023-1-thijs@raymakers.nl> References: <20240423111251.367023-1-thijs@raymakers.nl> Precedence: bulk X-Mailing-List: util-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Phil Auld Signed-off-by: Phil Auld Signed-off-by: Thijs Raymakers --- I noticed that the CI pipeline failed because the coresched test reported a "No such device" error. https://download.copr.fedorainfracloud.org/results/packit/util-linux-util-linux-2990/fedora-rawhide-x86_64/07343926-util-linux/builder-live.log.gz This happens because the following check in the kernel's kernel/sched/core_sched.c fails: > /* Called from prctl interface: PR_SCHED_CORE */ > int sched_core_share_pid(unsigned int cmd, pid_t pid, enum pid_type type, > unsigned long uaddr) > { > [snip] > > if (!static_branch_likely(&sched_smt_present)) > return -ENODEV; The prctl call will return ENODEV whenever SMT is not available, but the kernel is compiled with CONFIG_SCHED_CORE. I've added a check that skips the tests for coresched when this is the case. Thijs Interdiff against v10: diff --git a/schedutils/coresched.c b/schedutils/coresched.c index 7bc5c9d38..beeb01702 100644 --- a/schedutils/coresched.c +++ b/schedutils/coresched.c @@ -328,7 +328,7 @@ int main(int argc, char **argv) if (!is_core_sched_supported()) errx(EXIT_FAILURE, - _("No support for core scheduling found. Does your kernel" + _("No support for core scheduling found. Does your kernel " "support CONFIG_SCHED_CORE?")); sched_core_cookie cookie; diff --git a/tests/ts/schedutils/coresched b/tests/ts/schedutils/coresched index e34fa319f..debb8cbfc 100755 --- a/tests/ts/schedutils/coresched +++ b/tests/ts/schedutils/coresched @@ -22,6 +22,12 @@ if [[ $CORESCHED_TEST_KERNEL_SUPPORT_CMD == *"CONFIG_SCHED_CORE"* ]]; then ts_skip "Kernel has no CONFIG_SCHED_CORE support" fi +# Kernel and the machine must support SMT +CORESCHED_HAS_SMT_SUPPORT=$( +#include +#include +#include +#include + +#include "c.h" +#include "closestream.h" +#include "nls.h" +#include "strutils.h" + +// These definitions might not be defined in the header files, even if the +// prctl interface in the kernel accepts them as valid. +#ifndef PR_SCHED_CORE + #define PR_SCHED_CORE 62 +#endif +#ifndef PR_SCHED_CORE_GET + #define PR_SCHED_CORE_GET 0 +#endif +#ifndef PR_SCHED_CORE_CREATE + #define PR_SCHED_CORE_CREATE 1 +#endif +#ifndef PR_SCHED_CORE_SHARE_TO + #define PR_SCHED_CORE_SHARE_TO 2 +#endif +#ifndef PR_SCHED_CORE_SHARE_FROM + #define PR_SCHED_CORE_SHARE_FROM 3 +#endif +#ifndef PR_SCHED_CORE_SCOPE_THREAD + #define PR_SCHED_CORE_SCOPE_THREAD 0 +#endif +#ifndef PR_SCHED_CORE_SCOPE_THREAD_GROUP + #define PR_SCHED_CORE_SCOPE_THREAD_GROUP 1 +#endif +#ifndef PR_SCHED_CORE_SCOPE_PROCESS_GROUP + #define PR_SCHED_CORE_SCOPE_PROCESS_GROUP 2 +#endif + +typedef int sched_core_scope; +typedef unsigned long long sched_core_cookie; +typedef enum { + SCHED_CORE_CMD_GET, + SCHED_CORE_CMD_NEW, + SCHED_CORE_CMD_COPY, +} sched_core_cmd; + +struct args { + pid_t src; + pid_t dest; + sched_core_scope type; + sched_core_cmd cmd; + int exec_argv_offset; +}; + +static bool sched_core_verbose = false; + +static void __attribute__((__noreturn__)) usage(void) +{ + fputs(USAGE_HEADER, stdout); + fprintf(stdout, _(" %s [get] [--source ]\n"), + program_invocation_short_name); + fprintf(stdout, _(" %s new [-t ] --dest \n"), + program_invocation_short_name); + fprintf(stdout, _(" %s new [-t ] -- PROGRAM [ARGS...]\n"), + program_invocation_short_name); + fprintf(stdout, + _(" %s copy [--source ] [-t ] --dest \n"), + program_invocation_short_name); + fprintf(stdout, + _(" %s copy [--source ] [-t ] -- PROGRAM [ARGS...]\n"), + program_invocation_short_name); + + fputs(USAGE_SEPARATOR, stdout); + fputsln(_("Manage core scheduling cookies for tasks."), stdout); + + fputs(USAGE_FUNCTIONS, stdout); + fputsln(_(" get retrieve the core scheduling cookie of a PID"), + stdout); + fputsln(_(" new assign a new core scheduling cookie to an existing\n" + " PID or execute a program with a new cookie"), + stdout); + fputsln(_(" copy copy the core scheduling cookie from an existing PID\n" + " to another PID, or execute a program with that\n" + " copied cookie"), + stdout); + + fputs(USAGE_OPTIONS, stdout); + fprintf(stdout, + _(" -s, --source which PID to get the cookie from\n" + " If omitted, it is the PID of %s itself\n"), + program_invocation_short_name); + fputsln(_(" -d, --dest which PID to modify the cookie of\n"), + stdout); + fputsln(_(" -t, --dest-type type of the destination PID, or the type of the PID\n" + " when a new core scheduling cookie is created.\n" + " Can be one of the following: pid, tgid or pgid.\n" + " The default is tgid."), + stdout); + fputs(USAGE_SEPARATOR, stdout); + fputsln(_(" -v, --verbose verbose"), stdout); + fprintf(stdout, USAGE_HELP_OPTIONS(20)); + fprintf(stdout, USAGE_MAN_TAIL("coresched(1)")); + exit(EXIT_SUCCESS); +} + +#define bad_usage(FMT...) \ + do { \ + warnx(FMT); \ + errtryhelp(EXIT_FAILURE); \ + } while (0) + +static sched_core_cookie core_sched_get_cookie(pid_t pid) +{ + sched_core_cookie cookie = 0; + if (prctl(PR_SCHED_CORE, PR_SCHED_CORE_GET, pid, + PR_SCHED_CORE_SCOPE_THREAD, &cookie)) + err(EXIT_FAILURE, _("Failed to get cookie from PID %d"), pid); + return cookie; +} + +static void core_sched_create_cookie(pid_t pid, sched_core_scope type) +{ + if (prctl(PR_SCHED_CORE, PR_SCHED_CORE_CREATE, pid, type, 0)) + err(EXIT_FAILURE, _("Failed to create cookie for PID %d"), pid); +} + +static void core_sched_pull_cookie(pid_t from) +{ + if (prctl(PR_SCHED_CORE, PR_SCHED_CORE_SHARE_FROM, from, + PR_SCHED_CORE_SCOPE_THREAD, 0)) + err(EXIT_FAILURE, _("Failed to pull cookie from PID %d"), from); +} + +static void core_sched_push_cookie(pid_t to, sched_core_scope type) +{ + if (prctl(PR_SCHED_CORE, PR_SCHED_CORE_SHARE_TO, to, type, 0)) + err(EXIT_FAILURE, _("Failed to push cookie to PID %d"), to); +} + +static void core_sched_copy_cookie(pid_t from, pid_t to, + sched_core_scope to_type) +{ + core_sched_pull_cookie(from); + core_sched_push_cookie(to, to_type); + + if (sched_core_verbose) { + sched_core_cookie before = core_sched_get_cookie(from); + warnx(_("copied cookie 0x%llx from PID %d to PID %d"), before, + from, to); + } +} + +static void core_sched_get_and_print_cookie(pid_t pid) +{ + if (sched_core_verbose) { + sched_core_cookie after = core_sched_get_cookie(pid); + warnx(_("set cookie of PID %d to 0x%llx"), pid, after); + } +} + +static void core_sched_exec_with_cookie(struct args *args, char **argv) +{ + // Move the argument list to the first argument of the program + argv = &argv[args->exec_argv_offset]; + + // If a source PID is provided, try to copy the cookie from + // that PID. Otherwise, create a brand new cookie with the + // provided type. + if (args->src) { + core_sched_pull_cookie(args->src); + core_sched_get_and_print_cookie(args->src); + } else { + pid_t pid = getpid(); + core_sched_create_cookie(pid, args->type); + core_sched_get_and_print_cookie(pid); + } + + if (execvp(argv[0], argv)) + errexec(argv[0]); +} + +// If PR_SCHED_CORE is not recognized, or not supported on this system, +// then prctl will set errno to EINVAL. Assuming all other operands of +// prctl are valid, we can use errno==EINVAL as a check to see whether +// core scheduling is available on this system. +static bool is_core_sched_supported(void) +{ + sched_core_cookie cookie = 0; + if (prctl(PR_SCHED_CORE, PR_SCHED_CORE_GET, getpid(), + PR_SCHED_CORE_SCOPE_THREAD, &cookie)) + if (errno == EINVAL) + return false; + + return true; +} + +static sched_core_scope parse_core_sched_type(char *str) +{ + if (!strcmp(str, "pid")) + return PR_SCHED_CORE_SCOPE_THREAD; + else if (!strcmp(str, "tgid")) + return PR_SCHED_CORE_SCOPE_THREAD_GROUP; + else if (!strcmp(str, "pgid")) + return PR_SCHED_CORE_SCOPE_PROCESS_GROUP; + + bad_usage(_("'%s' is an invalid option. Must be one of pid/tgid/pgid"), + str); +} + +static void parse_and_verify_arguments(int argc, char **argv, struct args *args) +{ + int c; + + static const struct option longopts[] = { + { "source", required_argument, NULL, 's' }, + { "dest", required_argument, NULL, 'd' }, + { "dest-type", required_argument, NULL, 't' }, + { "verbose", no_argument, NULL, 'v' }, + { "version", no_argument, NULL, 'V' }, + { "help", no_argument, NULL, 'h' }, + { NULL, 0, NULL, 0 } + }; + + while ((c = getopt_long(argc, argv, "s:d:t:vVh", longopts, NULL)) != -1) + switch (c) { + case 's': + args->src = strtopid_or_err( + optarg, + _("Failed to parse PID for -s/--source")); + break; + case 'd': + args->dest = strtopid_or_err( + optarg, _("Failed to parse PID for -d/--dest")); + break; + case 't': + args->type = parse_core_sched_type(optarg); + break; + case 'v': + sched_core_verbose = true; + break; + case 'V': + print_version(EXIT_SUCCESS); + case 'h': + usage(); + default: + errtryhelp(EXIT_FAILURE); + } + + if (argc <= optind) { + args->cmd = SCHED_CORE_CMD_GET; + } else { + if (!strcmp(argv[optind], "get")) + args->cmd = SCHED_CORE_CMD_GET; + else if (!strcmp(argv[optind], "new")) + args->cmd = SCHED_CORE_CMD_NEW; + else if (!strcmp(argv[optind], "copy")) + args->cmd = SCHED_CORE_CMD_COPY; + else + bad_usage(_("Unknown function")); + + // Since we parsed an extra "option" outside of getopt_long, we have to + // increment optind manually. + ++optind; + } + + if (args->cmd == SCHED_CORE_CMD_GET && args->dest) + bad_usage(_("get does not accept the --dest option")); + + if (args->cmd == SCHED_CORE_CMD_NEW && args->src) + bad_usage(_("new does not accept the --source option")); + + // If the -s/--source option is not specified, it defaults to the PID + // of the current coresched process + if (args->cmd != SCHED_CORE_CMD_NEW && !args->src) + args->src = getpid(); + + // More arguments have been passed, which means that the user wants to run + // another program with a core scheduling cookie. + if (argc > optind) { + switch (args->cmd) { + case SCHED_CORE_CMD_GET: + bad_usage(_("bad usage of the get function")); + break; + case SCHED_CORE_CMD_NEW: + if (args->dest) + bad_usage(_( + "new requires either a -d/--dest or a command")); + else + args->exec_argv_offset = optind; + break; + case SCHED_CORE_CMD_COPY: + if (args->dest) + bad_usage(_( + "copy requires either a -d/--dest or a command")); + else + args->exec_argv_offset = optind; + break; + } + } else { + if (args->cmd == SCHED_CORE_CMD_NEW && !args->dest) + bad_usage(_( + "new requires either a -d/--dest or a command")); + if (args->cmd == SCHED_CORE_CMD_COPY && !args->dest) + bad_usage(_( + "copy requires either a -d/--dest or a command")); + } +} + +int main(int argc, char **argv) +{ + struct args args = { .type = PR_SCHED_CORE_SCOPE_THREAD_GROUP }; + + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + close_stdout_atexit(); + + parse_and_verify_arguments(argc, argv, &args); + + if (!is_core_sched_supported()) + errx(EXIT_FAILURE, + _("No support for core scheduling found. Does your kernel " + "support CONFIG_SCHED_CORE?")); + + sched_core_cookie cookie; + + switch (args.cmd) { + case SCHED_CORE_CMD_GET: + cookie = core_sched_get_cookie(args.src); + printf(_("cookie of pid %d is 0x%llx\n"), args.src, cookie); + break; + case SCHED_CORE_CMD_NEW: + if (args.exec_argv_offset) { + core_sched_exec_with_cookie(&args, argv); + } else { + core_sched_create_cookie(args.dest, args.type); + core_sched_get_and_print_cookie(args.dest); + } + break; + case SCHED_CORE_CMD_COPY: + if (args.exec_argv_offset) + core_sched_exec_with_cookie(&args, argv); + else + core_sched_copy_cookie(args.src, args.dest, args.type); + break; + default: + usage(); + } +} diff --git a/tests/commands.sh b/tests/commands.sh index 5674c5ff0..9eef92ccb 100644 --- a/tests/commands.sh +++ b/tests/commands.sh @@ -71,6 +71,7 @@ TS_CMD_COLCRT=${TS_CMD_COLCRT:-"${ts_commandsdir}colcrt"} TS_CMD_COLRM=${TS_CMD_COLRM:-"${ts_commandsdir}colrm"} TS_CMD_COL=${TS_CMD_COL:-"${ts_commandsdir}col"} TS_CMD_COLUMN=${TS_CMD_COLUMN:-"${ts_commandsdir}column"} +TS_CMD_CORESCHED=${TS_CMD_CORESCHED:-"${ts_commandsdir}coresched"} TS_CMD_ENOSYS=${TS_CMD_ENOSYS-"${ts_commandsdir}enosys"} TS_CMD_EJECT=${TS_CMD_EJECT-"${ts_commandsdir}eject"} TS_CMD_EXCH=${TS_CMD_EXCH-"${ts_commandsdir}exch"} diff --git a/tests/expected/schedutils/coresched-copy-from-child-to-parent b/tests/expected/schedutils/coresched-copy-from-child-to-parent new file mode 100644 index 000000000..5b9c40052 --- /dev/null +++ b/tests/expected/schedutils/coresched-copy-from-child-to-parent @@ -0,0 +1 @@ +DIFFERENT_COOKIE diff --git a/tests/expected/schedutils/coresched-copy-from-parent-to-nested-child b/tests/expected/schedutils/coresched-copy-from-parent-to-nested-child new file mode 100644 index 000000000..ecfc41142 --- /dev/null +++ b/tests/expected/schedutils/coresched-copy-from-parent-to-nested-child @@ -0,0 +1 @@ +SAME_COOKIE diff --git a/tests/expected/schedutils/coresched-get-cookie-own-pid b/tests/expected/schedutils/coresched-get-cookie-own-pid new file mode 100644 index 000000000..84f182cbe --- /dev/null +++ b/tests/expected/schedutils/coresched-get-cookie-own-pid @@ -0,0 +1 @@ +cookie of pid OWN_PID is PARENT_COOKIE diff --git a/tests/expected/schedutils/coresched-get-cookie-parent-pid b/tests/expected/schedutils/coresched-get-cookie-parent-pid new file mode 100644 index 000000000..e183e0402 --- /dev/null +++ b/tests/expected/schedutils/coresched-get-cookie-parent-pid @@ -0,0 +1 @@ +cookie of pid PARENT_PID is PARENT_COOKIE diff --git a/tests/expected/schedutils/coresched-new-child-with-new-cookie b/tests/expected/schedutils/coresched-new-child-with-new-cookie new file mode 100644 index 000000000..5b9c40052 --- /dev/null +++ b/tests/expected/schedutils/coresched-new-child-with-new-cookie @@ -0,0 +1 @@ +DIFFERENT_COOKIE diff --git a/tests/expected/schedutils/coresched-set-cookie-parent-pid.err b/tests/expected/schedutils/coresched-set-cookie-parent-pid.err new file mode 100644 index 000000000..e7318ffc2 --- /dev/null +++ b/tests/expected/schedutils/coresched-set-cookie-parent-pid.err @@ -0,0 +1 @@ +coresched: set cookie of PID PARENT_PID to PARENT_COOKIE diff --git a/tests/expected/schedutils/set-cookie-parent-pid b/tests/expected/schedutils/set-cookie-parent-pid new file mode 100644 index 000000000..e7318ffc2 --- /dev/null +++ b/tests/expected/schedutils/set-cookie-parent-pid @@ -0,0 +1 @@ +coresched: set cookie of PID PARENT_PID to PARENT_COOKIE diff --git a/tests/ts/schedutils/coresched b/tests/ts/schedutils/coresched new file mode 100755 index 000000000..debb8cbfc --- /dev/null +++ b/tests/ts/schedutils/coresched @@ -0,0 +1,89 @@ +#!/bin/bash +# SPDX-License-Identifier: EUPL-1.2 +# +# This file is part of util-linux +# +# Copyright (C) 2024 Thijs Raymakers +# Licensed under the EUPL v1.2 + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="coresched" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_CORESCHED" +ts_check_prog "tee" +ts_check_prog "sed" + +# If there is no kernel support, skip the test suite +CORESCHED_TEST_KERNEL_SUPPORT_CMD=$($TS_CMD_CORESCHED 2>&1) +if [[ $CORESCHED_TEST_KERNEL_SUPPORT_CMD == *"CONFIG_SCHED_CORE"* ]]; then + ts_skip "Kernel has no CONFIG_SCHED_CORE support" +fi + +# Kernel and the machine must support SMT +CORESCHED_HAS_SMT_SUPPORT=$(&1 1>&2 2>&3 \ + | sed "s/$$/PARENT_PID/g") +CORESCHED_PARENT_COOKIE=$(echo "$CORESCHED_OUTPUT" | sed 's/^.*\(0x.*$\)/\1/g') +if [ -z "$CORESCHED_PARENT_COOKIE" ]; then + ts_failed "empty value for CORESCHED_PARENT_COOKIE" +fi +CORESCHED_OUTPUT=$(echo "$CORESCHED_OUTPUT" \ + | sed "s/$CORESCHED_PARENT_COOKIE/PARENT_COOKIE/g") +echo "$CORESCHED_OUTPUT" >> "$TS_ERRLOG" +ts_finalize_subtest + +ts_init_subtest "get-cookie-parent-pid" +$TS_CMD_CORESCHED get -s $$ 2>> "$TS_ERRLOG" \ + | sed -e "s/$$/PARENT_PID/g" \ + -e "s/$CORESCHED_PARENT_COOKIE/PARENT_COOKIE/g" >> "$TS_OUTPUT" +ts_finalize_subtest + +ts_init_subtest "get-cookie-own-pid" +$TS_CMD_CORESCHED get 2>> "$TS_ERRLOG" \ + | sed -e "s/pid [0-9]\+/pid OWN_PID/g" \ + -e "s/$CORESCHED_PARENT_COOKIE/PARENT_COOKIE/g" >> "$TS_OUTPUT" +ts_finalize_subtest + +ts_init_subtest "new-child-with-new-cookie" +$TS_CMD_CORESCHED new -- "$TS_CMD_CORESCHED" get 2>> "$TS_ERRLOG" \ + | sed -e 's/^.*\(0x.*$\)/\1/g' \ + -e "s/$CORESCHED_PARENT_COOKIE/SAME_COOKIE/g" \ + -e "s/0x.*$/DIFFERENT_COOKIE/g" >> "$TS_OUTPUT" +ts_finalize_subtest + +ts_init_subtest "copy-from-parent-to-nested-child" +$TS_CMD_CORESCHED new -- /bin/bash -c \ + "$TS_CMD_CORESCHED copy -s $$ -- $TS_CMD_CORESCHED get" \ +2>> "$TS_ERRLOG" \ + | sed -e 's/^.*\(0x.*$\)/\1/g' \ + -e "s/$CORESCHED_PARENT_COOKIE/SAME_COOKIE/g" \ + -e "s/0x.*$/DIFFERENT_COOKIE/g" >> "$TS_OUTPUT" +ts_finalize_subtest + +ts_init_subtest "copy-from-child-to-parent" +$TS_CMD_CORESCHED new -- /bin/bash -c \ + "$TS_CMD_CORESCHED copy -s \$\$ -d $$" +$TS_CMD_CORESCHED get 2>> "$TS_ERRLOG" \ + | sed -e 's/^.*\(0x.*$\)/\1/g' \ + -e "s/$CORESCHED_PARENT_COOKIE/SAME_COOKIE/g" \ + -e "s/0x.*$/DIFFERENT_COOKIE/g" >> "$TS_OUTPUT" +ts_finalize_subtest + +ts_finalize -- 2.44.0