Skip to content

Commit 9326a21

Browse files
committed
fixup! test: rewrite sysprof test using managed execution
1 parent a05f98d commit 9326a21

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,57 +53,46 @@
5353
extern void *lj_ff_tostring(void);
5454
extern void *lj_fff_res1(void);
5555

56-
/* Sysprof "/dev/null" stream helpers. {{{ */
56+
/* Sysprof dummy stream helpers. {{{ */
5757

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

65-
struct devnull_ctx {
66-
/*
67-
* XXX: Dummy file descriptor to be used as "/dev/null"
68-
* context indicator in writer and on_stop callback.
69-
*/
70-
int fd;
64+
struct dummy_ctx {
7165
/* Buffer for data recorded by sysprof. */
7266
uint8_t buf[STREAM_BUFFER_SIZE];
7367
};
7468

69+
static struct dummy_ctx context;
70+
7571
static int stream_new(struct luam_Sysprof_Options *options)
7672
{
77-
struct devnull_ctx *ctx = calloc(1, sizeof(struct devnull_ctx));
78-
if (ctx == NULL)
79-
return PROFILE_ERRIO;
80-
81-
/* Set "/dev/null" context indicator. */
82-
ctx->fd = DEVNULL;
83-
options->ctx = ctx;
84-
options->buf = ctx->buf;
73+
/* Set dummy context. */
74+
options->ctx = &context;
75+
options->buf = (uint8_t *)&context.buf;
8576
options->len = STREAM_BUFFER_SIZE;
8677

8778
return PROFILE_SUCCESS;
8879
}
8980

9081
static int stream_delete(void *rawctx, uint8_t *buf)
9182
{
92-
struct devnull_ctx *ctx = rawctx;
93-
assert(ctx->fd == DEVNULL);
94-
free(ctx);
83+
assert(rawctx == &context);
84+
/* XXX: No need to release context memory. Just return. */
9585
return PROFILE_SUCCESS;
9686
}
9787

9888
static size_t stream_writer(const void **buf_addr, size_t len, void *rawctx)
9989
{
100-
struct devnull_ctx *ctx = rawctx;
101-
assert(ctx->fd == DEVNULL);
90+
assert(rawctx == &context);
10291
/* Do nothing, just return back to the profiler. */
10392
return STREAM_BUFFER_SIZE;
10493
}
10594

106-
/* }}} Sysprof "/dev/null" stream helpers. */
95+
/* }}} Sysprof dummy stream helpers. */
10796

10897
static int tracee(const char *luacode)
10998
{

0 commit comments

Comments
 (0)