Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 121311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:57:03+00:00 2026-05-11T03:57:03+00:00

Just some days ago I started looking into a unit test framework called check,

  • 0

Just some days ago I started looking into a unit test framework called check, and I intend to run the test on c code under Linux.

Now check and some well-designed code and some test code can help me to verify that the basic functionality is correct, I mean it is quite easy to just look at the variables in and response back and then decide if a function is correct or not.

But let’s say I want to test a dynamic memory structure with a lot of calls to malloc and free, and it turns out that I can put data in and get correct data back out again. But that does not prove that I have not broken some memory in the process, let’s say I forgot to free half of the memory and lost the pointers (a classical memleak). That code would probably pass most of the unit testing.

So now for the question: is it a good idea to run the entire unit test code with i.e. Valgrind and let him detect any malloc/free problems? (Or maybe compile in something like Electric Fence?)

It feels like a good idea, but I’m not sure what I’m getting myself into here…..


Update: Thanks Douglas and Jonathan, it seems like this is a good idea and something I should continue with 🙂

Update: Valgrind is a fun tool, however the first memleaks I found doing this was in the test framework and not my own code (quite funny though). So, a tip to the rest of you is to verify that the unit test framework you are using is not leaking before turning your own code upside down. An empty test case was all that was needed in my case, since then nothing but the unit test framework is running.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:57:04+00:00Added an answer on May 11, 2026 at 3:57 am

    We certainly do – it’s much easier to run valgrind against the unit tests than with the full program.

    Also any memory errors are localised to the area of code the unit test is testing which makes it easier to fix.

    Plus checking that you’ve fixed it is easier – because you’re running the unit test not a more complicated test against your full program.

    If you’re running valgrind in an automated fashion you probably want --error-exitcode=<number> [default: 0]

    Specifies an alternative exit code to return if Valgrind reported any errors in the run. When set to the default value (zero), the return value from Valgrind will always be the return value of the process being simulated. When set to a nonzero value, that value is returned instead, if Valgrind detects any errors. This is useful for using Valgrind as part of an automated test suite, since it makes it easy to detect test cases for which Valgrind has reported errors, just by inspecting return codes.

    http://valgrind.org/docs/manual/manual-core.html#manual-core.erropts

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 111k
  • Answers 111k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer AJAX would work. Simply have a method that returns the… May 11, 2026 at 9:48 pm
  • Editorial Team
    Editorial Team added an answer Short version: use BindingList<T>... Long version: A DataSource is typically… May 11, 2026 at 9:48 pm
  • Editorial Team
    Editorial Team added an answer "Null Device Driver" is available in the XPe Target Designer,… May 11, 2026 at 9:48 pm

Related Questions

Issue: Just started today, all references to any assembly outside of the solution fail
I want to get smarter in AJAX, but not sure which way to go.
We started some overseas merge replication 1 year ago and everything is going fine
My software went in production some days ago and now I want to argue

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.