-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3159 from grondo/plugin-improvement-project
improve support for shell plugin developers
- Loading branch information
Showing
14 changed files
with
241 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/************************************************************\ | ||
* Copyright 2020 Lawrence Livermore National Security, LLC | ||
* (c.f. AUTHORS, NOTICE.LLNS, COPYING) | ||
* | ||
* This file is part of the Flux resource manager framework. | ||
* For details, see https://github.com/flux-framework. | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0 | ||
\************************************************************/ | ||
|
||
#if HAVE_CONFIG_H | ||
#include "config.h" | ||
#endif | ||
#include <stdio.h> | ||
#include <stdarg.h> | ||
#include <string.h> | ||
#include <errno.h> | ||
|
||
#include <jansson.h> | ||
#include <flux/core.h> | ||
#include <flux/shell.h> | ||
|
||
#include "src/common/libtap/tap.h" | ||
|
||
static int die (const char *fmt, ...) | ||
{ | ||
va_list ap; | ||
va_start (ap, fmt); | ||
vfprintf (stderr, fmt, ap); | ||
va_end (ap); | ||
return -1; | ||
} | ||
|
||
static int check_setopt (flux_plugin_t *p, | ||
const char *topic, | ||
flux_plugin_arg_t *args, | ||
void *data) | ||
{ | ||
json_t *options = NULL; | ||
|
||
flux_shell_t *shell = flux_plugin_get_shell (p); | ||
if (!p) | ||
return die ("flux_plugin_get_shell\n"); | ||
|
||
ok (flux_shell_info_unpack (shell, | ||
"{s:{s:{s:{s:{s:o}}}}}", | ||
"jobspec", | ||
"attributes", | ||
"system", | ||
"shell", | ||
"options", &options) < 0 && errno == ENOENT, | ||
"flux_shell_info_unpack shell options returns ENOENT"); | ||
|
||
/* A shell plugin should be able to call setopt even though | ||
* no shell options were currently set in jobspec. | ||
*/ | ||
ok (flux_shell_setopt (shell, "new", "42") == 0, | ||
"flux_shell_setopt of new option works"); | ||
|
||
return exit_status () == 0 ? 0 : -1; | ||
} | ||
|
||
int flux_plugin_init (flux_plugin_t *p) | ||
{ | ||
plan (NO_PLAN); | ||
ok (flux_plugin_add_handler (p, "shell.init", check_setopt, NULL) == 0, | ||
"flux_plugin_add_handler works"); | ||
return 0; | ||
} | ||
|
||
/* | ||
* vi: ts=4 sw=4 expandtab | ||
*/ |
Oops, something went wrong.