Hi Jackub, May be you can include the attached file here http://jhrozek.fedorapeople.org/cmocka/ It's an example showing complete mocking of rect.c interface.
thanks, Abhishek On Thu, Feb 28, 2013 at 3:10 PM, Jakub Hrozek <jhro...@redhat.com> wrote: > On Thu, Feb 28, 2013 at 01:17:41AM +0530, Abhishek Singh wrote: > > Hi All, > > > > This is Abhishek Kumar Singh. I want to apply for Gsoc this year. I have > > sound Knowledge of C, C++, Python, bash script, pytest, unit testing > > framework, code coverage. Currently am learning cmocka unit testing > > > > I will start with the idea "SSSD Test Suite Coverage" as a part of my > Gsoc > > 2013 Proposal, which includes writing unit tests for SSSD using cmocka > > library. I had a discussion with Jakub Hrozek(jhrozek) who is my mentor. > > Please guide me through your valuable suggestions. > > > > Thanks, > > Abhishek > > Hi Abhishek! > > We've talked with Abhishek on #sssd on IRC and drafted a rough plan on > what the GSoC work might look like: > https://fedorahosted.org/sssd/wiki/DesignDocs/TestCoverage > > Currently Abhishek is looking at cmocka and started looking at SSSD from > user point of view - how to set it up etc. > > The result of his work should be a better test coverage. > > Welcome aboard Abhishek and good luck! > _______________________________________________ > sssd-devel mailing list > sssd-devel@lists.fedorahosted.org > https://lists.fedorahosted.org/mailman/listinfo/sssd-devel >
/* An example showing complete mocking of interface */ #include <stdio.h> #include <stddef.h> #include <stdlib.h> #include <setjmp.h> #include <errno.h> #include <cmocka.h> #include "rect.h" int new_rect(const int height, const int width, struct rect **_r) { *_r = (struct rect *) mock(); return (int) mock(); } void free_rect(struct rect *r) { return;/* noops */ } int area_rect(const struct rect *r) { return (int) mock(); } void test_create_and_print_rect(void **state) { struct rect r = {.width = 8, .height = 5}; will_return(new_rect, &r); will_return(new_rect, 0); will_return(area_rect, 40); /* testing by using mock object */ assert_int_equal(create_and_print_rect(5, 2), 0); } int main() { const UnitTest tests[]={ unit_test(test_create_and_print_rect), }; return run_tests(tests); }
_______________________________________________ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/sssd-devel