Skip to content

Commit

Permalink
fixup! test: rewrite sysprof test using managed execution
Browse files Browse the repository at this point in the history
  • Loading branch information
igormunkin committed Dec 5, 2023
1 parent a05f98d commit 9326a21
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,57 +53,46 @@
extern void *lj_ff_tostring(void);
extern void *lj_fff_res1(void);

/* Sysprof "/dev/null" stream helpers. {{{ */
/* Sysprof dummy stream helpers. {{{ */

/*
* Yep, 8Mb. Tuned in order not to bother the platform with too
* often flushes.
*/
#define STREAM_BUFFER_SIZE (8 * 1024 * 1024)
#define DEVNULL -1

struct devnull_ctx {
/*
* XXX: Dummy file descriptor to be used as "/dev/null"
* context indicator in writer and on_stop callback.
*/
int fd;
struct dummy_ctx {
/* Buffer for data recorded by sysprof. */
uint8_t buf[STREAM_BUFFER_SIZE];
};

static struct dummy_ctx context;

static int stream_new(struct luam_Sysprof_Options *options)
{
struct devnull_ctx *ctx = calloc(1, sizeof(struct devnull_ctx));
if (ctx == NULL)
return PROFILE_ERRIO;

/* Set "/dev/null" context indicator. */
ctx->fd = DEVNULL;
options->ctx = ctx;
options->buf = ctx->buf;
/* Set dummy context. */
options->ctx = &context;
options->buf = (uint8_t *)&context.buf;
options->len = STREAM_BUFFER_SIZE;

return PROFILE_SUCCESS;
}

static int stream_delete(void *rawctx, uint8_t *buf)
{
struct devnull_ctx *ctx = rawctx;
assert(ctx->fd == DEVNULL);
free(ctx);
assert(rawctx == &context);
/* XXX: No need to release context memory. Just return. */
return PROFILE_SUCCESS;
}

static size_t stream_writer(const void **buf_addr, size_t len, void *rawctx)
{
struct devnull_ctx *ctx = rawctx;
assert(ctx->fd == DEVNULL);
assert(rawctx == &context);
/* Do nothing, just return back to the profiler. */
return STREAM_BUFFER_SIZE;
}

/* }}} Sysprof "/dev/null" stream helpers. */
/* }}} Sysprof dummy stream helpers. */

static int tracee(const char *luacode)
{
Expand Down

0 comments on commit 9326a21

Please sign in to comment.