[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is cm_print_error() intended to be a private function?


On Friday 01 April 2016 11:39:56 Edward Baudrez wrote:
> Hi
> 

Hi,

please remind me after April 12th. I don't have time before that date to look 
into anything.

Thanks.

> 
> A (fairly) new user of cmocka here. I'm exploring cmocka (there is a
> lot to like about it!), and one of the things I'm looking for is
> extending cmocka with my own custom-made assertions (somewhat like in
> Perl, if you happen to be into that, where you have file_exists_ok()
> and all sorts of test functions). For example, I tried this:
> 
> #include <unistd.h>
> #include <stdarg.h>
> #include <setjmp.h>
> #include <cmocka.h>
> 
> #define assert_path_exists(p) \
>     _assert_path_exists(p, __FILE__, __LINE__)
> 
> static void
> _assert_path_exists(const char *path, const char * const file, const int
> line) {
>     int exists = (access(path, F_OK) == 0);
>     if (!exists) {
>         cm_print_error("path '%s' does not exist\n", path);
>         _fail(file, line);
>     }
> }
> 
> (I basically copied from existing cmocka assert_xxx() functions.) This
> works fine, but it depends on the library exporting cm_print_error()
> and _fail(). They ARE exported in my current build of cmocka (1.0.1),
> but I've just stumbled upon the file cmocka.def in the src/ directory,
> which does not list cm_print_error() (it does list _fail(), though).
> While this export list does not seem to be enforced, I wonder if you
> really meant cm_print_error() to be a private function. That would
> prevent me from using it from custom-made assertions, though. Any
> comments?
> 
> 
> 
> Thank you for the very nice work and best regards!
> Edward Baudrez

-- 
Andreas Schneider                   GPG-ID: CC014E3D
www.cryptomilk.org                asn@xxxxxxxxxxxxxx

Follow-Ups:
Re: Is cm_print_error() intended to be a private function?Edward Baudrez <edward.baudrez@xxxxxxxxx>
References:
Is cm_print_error() intended to be a private function?Edward Baudrez <edward.baudrez@xxxxxxxxx>