expr.c (e80b500370e71b8cd7dd64be4080cee0a3e5068f) | expr.c (4a4a9bf9075fbc753ab20f05347fd1482d4801e4) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2#include "util/cputopo.h" 3#include "util/debug.h" 4#include "util/expr.h" 5#include "util/hashmap.h" 6#include "util/header.h" 7#include "util/smt.h" 8#include "tests.h" --- 171 unchanged lines hidden (view full) --- 180 } 181 /* The expression is a constant 1.0 without needing to evaluate EVENT1. */ 182 expr__ctx_clear(ctx); 183 TEST_ASSERT_VAL("find ids", 184 expr__find_ids("1.0 if EVENT1 > 100.0 else 1.0", 185 NULL, ctx) == 0); 186 TEST_ASSERT_VAL("find ids", hashmap__size(ctx->ids) == 0); 187 | 1// SPDX-License-Identifier: GPL-2.0 2#include "util/cputopo.h" 3#include "util/debug.h" 4#include "util/expr.h" 5#include "util/hashmap.h" 6#include "util/header.h" 7#include "util/smt.h" 8#include "tests.h" --- 171 unchanged lines hidden (view full) --- 180 } 181 /* The expression is a constant 1.0 without needing to evaluate EVENT1. */ 182 expr__ctx_clear(ctx); 183 TEST_ASSERT_VAL("find ids", 184 expr__find_ids("1.0 if EVENT1 > 100.0 else 1.0", 185 NULL, ctx) == 0); 186 TEST_ASSERT_VAL("find ids", hashmap__size(ctx->ids) == 0); 187 |
188 /* The expression is a constant 0.0 without needing to evaluate EVENT1. */ 189 expr__ctx_clear(ctx); 190 TEST_ASSERT_VAL("find ids", 191 expr__find_ids("0 & EVENT1 > 0", NULL, ctx) == 0); 192 TEST_ASSERT_VAL("find ids", hashmap__size(ctx->ids) == 0); 193 expr__ctx_clear(ctx); 194 TEST_ASSERT_VAL("find ids", 195 expr__find_ids("EVENT1 > 0 & 0", NULL, ctx) == 0); 196 TEST_ASSERT_VAL("find ids", hashmap__size(ctx->ids) == 0); 197 expr__ctx_clear(ctx); 198 TEST_ASSERT_VAL("find ids", 199 expr__find_ids("1 & EVENT1 > 0", NULL, ctx) == 0); 200 TEST_ASSERT_VAL("find ids", hashmap__size(ctx->ids) == 1); 201 TEST_ASSERT_VAL("find ids", hashmap__find(ctx->ids, "EVENT1", &val_ptr)); 202 expr__ctx_clear(ctx); 203 TEST_ASSERT_VAL("find ids", 204 expr__find_ids("EVENT1 > 0 & 1", NULL, ctx) == 0); 205 TEST_ASSERT_VAL("find ids", hashmap__size(ctx->ids) == 1); 206 TEST_ASSERT_VAL("find ids", hashmap__find(ctx->ids, "EVENT1", &val_ptr)); 207 208 /* The expression is a constant 1.0 without needing to evaluate EVENT1. */ 209 expr__ctx_clear(ctx); 210 TEST_ASSERT_VAL("find ids", 211 expr__find_ids("1 | EVENT1 > 0", NULL, ctx) == 0); 212 TEST_ASSERT_VAL("find ids", hashmap__size(ctx->ids) == 0); 213 expr__ctx_clear(ctx); 214 TEST_ASSERT_VAL("find ids", 215 expr__find_ids("EVENT1 > 0 | 1", NULL, ctx) == 0); 216 TEST_ASSERT_VAL("find ids", hashmap__size(ctx->ids) == 0); 217 expr__ctx_clear(ctx); 218 TEST_ASSERT_VAL("find ids", 219 expr__find_ids("0 | EVENT1 > 0", NULL, ctx) == 0); 220 TEST_ASSERT_VAL("find ids", hashmap__size(ctx->ids) == 1); 221 TEST_ASSERT_VAL("find ids", hashmap__find(ctx->ids, "EVENT1", &val_ptr)); 222 expr__ctx_clear(ctx); 223 TEST_ASSERT_VAL("find ids", 224 expr__find_ids("EVENT1 > 0 | 0", NULL, ctx) == 0); 225 TEST_ASSERT_VAL("find ids", hashmap__size(ctx->ids) == 1); 226 TEST_ASSERT_VAL("find ids", hashmap__find(ctx->ids, "EVENT1", &val_ptr)); 227 |
|
188 /* Test toplogy constants appear well ordered. */ 189 expr__ctx_clear(ctx); 190 TEST_ASSERT_VAL("#num_cpus", expr__parse(&num_cpus, ctx, "#num_cpus") == 0); 191 TEST_ASSERT_VAL("#num_cores", expr__parse(&num_cores, ctx, "#num_cores") == 0); 192 TEST_ASSERT_VAL("#num_cpus >= #num_cores", num_cpus >= num_cores); 193 TEST_ASSERT_VAL("#num_dies", expr__parse(&num_dies, ctx, "#num_dies") == 0); 194 TEST_ASSERT_VAL("#num_cores >= #num_dies", num_cores >= num_dies); 195 TEST_ASSERT_VAL("#num_packages", expr__parse(&num_packages, ctx, "#num_packages") == 0); --- 13 unchanged lines hidden (view full) --- 209 */ 210 expr__ctx_clear(ctx); 211 TEST_ASSERT_VAL("source count", 212 expr__find_ids("source_count(EVENT1)", 213 NULL, ctx) == 0); 214 TEST_ASSERT_VAL("source count", hashmap__size(ctx->ids) == 1); 215 TEST_ASSERT_VAL("source count", hashmap__find(ctx->ids, "EVENT1", &val_ptr)); 216 | 228 /* Test toplogy constants appear well ordered. */ 229 expr__ctx_clear(ctx); 230 TEST_ASSERT_VAL("#num_cpus", expr__parse(&num_cpus, ctx, "#num_cpus") == 0); 231 TEST_ASSERT_VAL("#num_cores", expr__parse(&num_cores, ctx, "#num_cores") == 0); 232 TEST_ASSERT_VAL("#num_cpus >= #num_cores", num_cpus >= num_cores); 233 TEST_ASSERT_VAL("#num_dies", expr__parse(&num_dies, ctx, "#num_dies") == 0); 234 TEST_ASSERT_VAL("#num_cores >= #num_dies", num_cores >= num_dies); 235 TEST_ASSERT_VAL("#num_packages", expr__parse(&num_packages, ctx, "#num_packages") == 0); --- 13 unchanged lines hidden (view full) --- 249 */ 250 expr__ctx_clear(ctx); 251 TEST_ASSERT_VAL("source count", 252 expr__find_ids("source_count(EVENT1)", 253 NULL, ctx) == 0); 254 TEST_ASSERT_VAL("source count", hashmap__size(ctx->ids) == 1); 255 TEST_ASSERT_VAL("source count", hashmap__find(ctx->ids, "EVENT1", &val_ptr)); 256 |
257 /* has_event returns 1 when an event exists. */ 258 expr__add_id_val(ctx, strdup("cycles"), 2); 259 ret = test(ctx, "has_event(cycles)", 1); 260 |
|
217 expr__ctx_free(ctx); 218 219 return 0; 220} 221 222DEFINE_SUITE("Simple expression parser", expr); | 261 expr__ctx_free(ctx); 262 263 return 0; 264} 265 266DEFINE_SUITE("Simple expression parser", expr); |