summaryrefslogtreecommitdiff
path: root/src/bin/exactness
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-27 09:14:45 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2020-03-31 14:56:23 +0200
commit7891e8582bc9bfffa77e21e595306629a1c65d30 (patch)
treeb2a6931c299ca3d47ccd353028d047f9432554ef /src/bin/exactness
parent4ecc94f84afdb0d627c9f1809786d33300f23c85 (diff)
exactness_recorder: move to preload
this is now not a binary anymore, that dlopen's a binary, it is now a library, that can be loaded using LD_PRELOAD. EXACTNESS_DEST is used for the path of the .exu file. EXACTNESS_FONTS_DIR is used to get the fonts directory Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org> Differential Revision: https://phab.enlightenment.org/D11610
Diffstat (limited to 'src/bin/exactness')
-rw-r--r--src/bin/exactness/meson.build2
-rw-r--r--src/bin/exactness/recorder.c206
2 files changed, 82 insertions, 126 deletions
diff --git a/src/bin/exactness/meson.build b/src/bin/exactness/meson.build
index 4dbfc73d1f..405cb240de 100644
--- a/src/bin/exactness/meson.build
+++ b/src/bin/exactness/meson.build
@@ -37,7 +37,7 @@ exactness_play_bin = executable('exactness_play',
37 install: true, 37 install: true,
38 ) 38 )
39 39
40exactness_record_bin = executable('exactness_record', 40exactness_record_bin = library('exactness_record',
41 [ 'recorder.c', 'common.c', 'common.h' ], 41 [ 'recorder.c', 'common.c', 'common.h' ],
42 dependencies: [ elementary ], 42 dependencies: [ elementary ],
43 c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"', 43 c_args: '-DDATA_DIR="'+join_paths(dir_data, 'exactness')+'"',
diff --git a/src/bin/exactness/recorder.c b/src/bin/exactness/recorder.c
index 67b7becd57..6c881f950f 100644
--- a/src/bin/exactness/recorder.c
+++ b/src/bin/exactness/recorder.c
@@ -7,6 +7,10 @@
7#include <getopt.h> 7#include <getopt.h>
8#include <unistd.h> 8#include <unistd.h>
9 9
10#ifdef HAVE_DLSYM
11# include <dlfcn.h>
12#endif
13
10#include <sys/types.h> 14#include <sys/types.h>
11#ifdef HAVE_SYS_SYSINFO_H 15#ifdef HAVE_SYS_SYSINFO_H
12# include <sys/sysinfo.h> 16# include <sys/sysinfo.h>
@@ -224,8 +228,7 @@ static Evas *
224_my_evas_new(int w EINA_UNUSED, int h EINA_UNUSED) 228_my_evas_new(int w EINA_UNUSED, int h EINA_UNUSED)
225{ 229{
226 Evas *e; 230 Evas *e;
227 if (!_evas_new) return NULL; 231 e = evas_new();
228 e = _evas_new();
229 if (e) 232 if (e)
230 { 233 {
231 INF("New Evas\n"); 234 INF("New Evas\n");
@@ -290,147 +293,100 @@ _setup_ee_creation(void)
290 _last_timestamp = ecore_time_get() * 1000; 293 _last_timestamp = ecore_time_get() * 1000;
291} 294}
292 295
296#ifdef HAVE_DLSYM
297# define ORIGINAL_CALL_T(t, name, ...) \
298 t (*_original_init_cb)(); \
299 _original_init_cb = dlsym(RTLD_NEXT, name); \
300 original_return = _original_init_cb(__VA_ARGS__);
301#else
302# define ORIGINAL_CALL_T(t, name, ...) \
303 printf("THIS IS NOT SUPPORTED ON WINDOWS\n"); \
304 abort();
305#endif
293 306
294static const Ecore_Getopt optdesc = { 307#define ORIGINAL_CALL(name, ...) \
295 "exactness_record", 308 ORIGINAL_CALL_T(int, name, __VA_ARGS__)
296 "%prog [options] <-v|-t|-h> command", 309
297 PACKAGE_VERSION, 310EAPI int
298 "(C) 2017 Enlightenment", 311eina_init(void)
299 "BSD",
300 "A scenario recorder for EFL based applications.\n"
301 "\tF1 - Request stabilization\n"
302 "\tF2 - Request shot\n"
303 "\tF3 - Request to save the scenario\n",
304 1,
305 {
306 ECORE_GETOPT_STORE_STR('t', "test", "Name of the filename where to store the test."),
307 ECORE_GETOPT_STORE_STR('f', "fonts-dir", "Specify a directory of the fonts that should be used."),
308
309 ECORE_GETOPT_LICENSE('L', "license"),
310 ECORE_GETOPT_COPYRIGHT('C', "copyright"),
311 ECORE_GETOPT_VERSION('V', "version"),
312 ECORE_GETOPT_HELP('h', "help"),
313 ECORE_GETOPT_SENTINEL
314 }
315};
316
317int main(int argc, char **argv)
318{ 312{
319 char *dest = NULL, *eq; 313 int original_return;
320 char *fonts_dir = NULL;
321 int pret = 1, opt_args = 0;
322 Eina_Bool want_quit = EINA_FALSE;
323 _evas_new = NULL;
324
325 Ecore_Getopt_Value values[] = {
326 ECORE_GETOPT_VALUE_STR(dest),
327 ECORE_GETOPT_VALUE_STR(fonts_dir),
328
329 ECORE_GETOPT_VALUE_BOOL(want_quit),
330 ECORE_GETOPT_VALUE_BOOL(want_quit),
331 ECORE_GETOPT_VALUE_BOOL(want_quit),
332 ECORE_GETOPT_VALUE_BOOL(want_quit),
333 ECORE_GETOPT_VALUE_NONE
334 };
335
336 _log_domain = eina_log_domain_register("exactness_recorder", NULL);
337
338 if (!ecore_evas_init())
339 return EXIT_FAILURE;
340
341 opt_args = ecore_getopt_parse(&optdesc, values, argc, argv);
342 if (opt_args < 0)
343 {
344 fprintf(stderr, "Failed parsing arguments.\n");
345 goto end;
346 }
347 if (want_quit) goto end;
348 314
349 /* Check for a sentinel */ 315 ORIGINAL_CALL("eina_init");
350 if (argv[opt_args] && !strcmp(argv[opt_args], "--")) opt_args++;
351 316
352 /* Check for env variables */ 317 if (original_return == 1)
353 do
354 { 318 {
355 eq = argv[opt_args] ? strchr(argv[opt_args], '=') : NULL; 319 _log_domain = eina_log_domain_register("exactness_recorder", NULL);
356 if (eq)
357 {
358 char *var = malloc(eq - argv[opt_args] + 1);
359 memcpy(var, argv[opt_args], eq - argv[opt_args]);
360 var[eq - argv[opt_args]] = '\0';
361 setenv(var, eq + 1, 1);
362 opt_args++;
363 }
364 } while (eq);
365 _out_filename = eina_stringshare_add(dest);
366 320
367 if (!_out_filename) 321 _out_filename = getenv("EXACTNESS_DEST");
368 { 322 _setup_unit();
369 fprintf(stderr, "no test file specified\n"); 323 if (!_setup_fonts_dir(getenv("EXACTNESS_FONTS_DIR")))
370 goto end; 324 return -1;
371 }
372 else
373 {
374 const char *_test_name;
375 char *slash = strrchr(_out_filename, '/');
376 if (slash) _test_name = strdup(slash + 1);
377 else _test_name = strdup(_out_filename);
378 char *dot = strrchr(_test_name, '.');
379 if (dot) *dot = '\0';
380 if (slash)
381 {
382 *slash = '\0';
383 if (!ecore_file_mkpath(_out_filename))
384 {
385 fprintf(stderr, "Can't create %s\n", _out_filename);
386 goto end;
387 }
388 *slash = '/';
389 }
390 }
391 if (strcmp(_out_filename + strlen(_out_filename) - 4,".exu"))
392 {
393 fprintf(stderr, "A file with a exu extension is required - %s invalid\n", _out_filename);
394 goto end;
395 }
396 325
397 if (!argv[opt_args]) 326 _setup_shot_key();
398 {
399 fprintf(stderr, "no program specified\nUse -h for more information\n");
400 goto end;
401 } 327 }
402 328
403 _setup_unit(); 329 return original_return;
404 if (!_setup_fonts_dir(fonts_dir)) 330}
405 goto end;
406 331
407 /* Replace the current command line to hide the Exactness part */ 332EAPI int
408 char **new_argv; 333ecore_evas_init(void)
334{
335 int original_return;
409 336
410 new_argv = calloc(argc - opt_args + 1, sizeof(char*)); 337 ORIGINAL_CALL("ecore_evas_init")
411 338
412 for (int i = 0; i < argc - opt_args + 1; ++i) 339 if (original_return == 1)
413 { 340 {
414 if (i < argc - opt_args) 341 _setup_ee_creation();
415 new_argv[i] = argv[opt_args + i]; 342
416 else
417 new_argv[i] = NULL;
418 } 343 }
419 344
420 _setup_shot_key(); 345 return original_return;
421 _setup_ee_creation(); 346}
422 347
423 pret = ex_prg_invoke(ex_prg_full_path_guess(argv[opt_args]), argc - opt_args, new_argv, EINA_FALSE); 348//hook, to hook in our theme
349EAPI int
350elm_init(int argc, char **argv)
351{
352 int original_return;
353 ORIGINAL_CALL("elm_init", argc, argv)
354
355 if (original_return == 1)
356 ex_prepare_elm_overloay();
357
358 return original_return;
359}
424 360
361EAPI void
362ecore_main_loop_begin(void)
363{
364 int original_return;
365 ORIGINAL_CALL("ecore_main_loop_begin")
425 _output_write(); 366 _output_write();
426 //free_events(_events_list, EINA_TRUE); 367 (void)original_return;
427 //_events_list = NULL; 368}
369
370EAPI Eina_Value*
371efl_loop_begin(Eo *obj)
372{
373 Eina_Value *original_return;
374 ORIGINAL_CALL_T(Eina_Value*, "efl_loop_begin", obj);
375 _output_write();
376 return original_return;
377}
428 378
429 pret = 0; 379EAPI int
380eina_shutdown(void)
381{
382 int original_return;
383 static Eina_Bool output_written = EINA_FALSE;
384 ORIGINAL_CALL("eina_shutdown")
385 if (original_return == 1 && !output_written)
386 {
387 output_written = EINA_TRUE;
388 _output_write();
389 }
430 390
431end: 391 return original_return;
432 ecore_evas_shutdown();
433 eina_log_domain_unregister(_log_domain);
434 _log_domain = -1;
435 return pret;
436} 392}