Skip to content

Commit

Permalink
Add CFG test with more node details.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Feb 9, 2024
1 parent aa18b2a commit b616428
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Binary file added elf/analysis/x86_cfg_node_details_test
Binary file not shown.
39 changes: 39 additions & 0 deletions src/graphs/cfg_node_details_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-FileCopyrightText: 2023 Rot127 <[email protected]>
// SPDX-License-Identifier: LGPL-3.0-only

/**
* \file Tests for CFG generation.
*/

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

typedef struct {
void (*fcn_a)();
void (*fcn_b)();
} Dummy;

void endless() {
endless:
goto endless;
}

void print_something() { printf("something"); }

int main() {
unsigned int a = rand();
Dummy d = {
.fcn_a = endless,
.fcn_b = print_something,
};
if (a == 0xdead) {
// Bad luck
d.fcn_a();
} else if (a == 0xc0ffee) {
abort();
} else {
d.fcn_b();
}
return a;
}

0 comments on commit b616428

Please sign in to comment.