From owner-freebsd-testing@freebsd.org Thu Sep 28 06:42:52 2017 Return-Path: Delivered-To: freebsd-testing@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7300DE2A8D1 for ; Thu, 28 Sep 2017 06:42:52 +0000 (UTC) (envelope-from shivanshrai84@gmail.com) Received: from mail-yw0-f175.google.com (mail-yw0-f175.google.com [209.85.161.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3822472420; Thu, 28 Sep 2017 06:42:51 +0000 (UTC) (envelope-from shivanshrai84@gmail.com) Received: by mail-yw0-f175.google.com with SMTP id u205so347744ywa.5; Wed, 27 Sep 2017 23:42:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QLQBst0OWQ3q2TTxVNLwYGA+T+gJvBVyyFon8QpS6l4=; b=SUc3DNNyeZhUpqQdTLnTwmEd9k1FwvkUGO+CCHfIeEM0tjP+dQDjW+zDLS0AEpeg6B AxgbBtZog2Ch0gB3OjENexNN3uJ5rgRiBAvjUSZpBlQtJJJ9AeZF2o7b5E/Gopd21Tl9 AuEgATQWgsOG/YltPPIiK0tE19YtLLsOwcRAmfi+JQyhhA5fh7i7pnUIvBKXwsgEx2AT FXTJAgPJRamJ5IW1egK7vBVSbY2rxnBxRVkpOh3fRd7o6+Sifb/cUgZoKSpVHzJ3H9G9 bMXaIRcbPIrSF+qY/4KI433NqFnmx+xA5wcxkxYp7UVW5Gb6xOsHu9Xyx9zy3+goRhZ5 mYiw== X-Gm-Message-State: AHPjjUgH0Y+7X54v+NCIMTu2tnyDI88XeLfmRlMEw2AQc5mIV8MwuIBv kxvGQIjhIn7+cYwPuNl/CWU4QA== X-Received: by 10.37.14.67 with SMTP id 64mr2996288ybo.122.1506580576616; Wed, 27 Sep 2017 23:36:16 -0700 (PDT) Received: from mail-io0-f174.google.com (mail-io0-f174.google.com. [209.85.223.174]) by smtp.gmail.com with ESMTPSA id n131sm293822ywb.107.2017.09.27.23.36.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Sep 2017 23:36:15 -0700 (PDT) Received: by mail-io0-f174.google.com with SMTP id w94so694797ioi.7; Wed, 27 Sep 2017 23:36:15 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCgM4PWn4WAgLiICAzMMP/mCKObz4qCkGkP9FonRqWSVDjiWsjsFLJzh71pBZo+Esb1KRXUtEv4ZcGn466JxN8= X-Received: by 10.107.181.138 with SMTP id e132mr5785767iof.53.1506580574743; Wed, 27 Sep 2017 23:36:14 -0700 (PDT) MIME-Version: 1.0 References: <20170924070506.GQ64616@funkthat.com> In-Reply-To: From: Shivansh Rai Date: Thu, 28 Sep 2017 06:36:03 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: suggestion library for mocking C functions To: Alan Somers , John-Mark Gurney Cc: "freebsd-testing@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-testing@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Testing on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Sep 2017 06:42:52 -0000 To add to the information by asomers@, this comment [1] might also be relevant. [1]: https://github.com/google/cmockery/pull/30#issuecomment-251064107 Regards, -- Shivansh On Sun, Sep 24, 2017 at 9:52 PM Alan Somers wrote: > On Sun, Sep 24, 2017 at 1:05 AM, John-Mark Gurney > wrote: > > Is there a recommended/supported library for mocking C functions? > > > > I want to write some test cases for functions that call other code > > in the same compilation unit that I want to be able to mock. > > > > There are a few out there, but was wondering if anyone has suggestions? > > > > Thanks. > > > > -- > > John-Mark Gurney Voice: +1 415 225 5579 > <(415)%20225-5579> > > There is no good C mocking library. The language simply doesn't > provide a good way to do it. CMockery is the best I've seen. > However, it's got some big limitations because it relies on the linker > to swap out function implementations. Your other option is to use a > C++ mocking library. It's usually possible to build your application > as C, but build the tests as C++. However, you'll still need to make > a few modifications to the application source to be able to mock > functions. You can probably hide it all in the preprocessor. If you > go this route, I recommend googletest, which nowadays includes mocking > functionality too. > > https://github.com/google/cmockery > https://github.com/google/googletest > > -Alan > _______________________________________________ > freebsd-testing@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-testing > To unsubscribe, send any mail to "freebsd-testing-unsubscribe@freebsd.org" >