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

  • SEARCH
  • Home
  • 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 3598554
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:15:24+00:00 2026-05-18T20:15:24+00:00

each source file has a function: unsigned char test(){ //return true if tests succceed

  • 0

each source file has a function:

unsigned char test(){
    //return true if tests succceed false otherwise
}

Everytime the sourcefile gets recompiled I want the test function of that file to be run on execution of the executable and if the tests return false to halt. However, I want only code whose test code hasnt been run since build.

I was thinking that I could use the makefile system to help with this problem since makefiles will only recompile changed code which is exactly what i want. Therefore, I was thinking of adding something to the command line arguments. I saw an example in which they used echo and date to add a time last modified. The code would write the time last modified to a save file on a successful execution of the test code with which it will compare to the next time.

Is there a better way? One that doesnt rely on make? At the least is there a way without relying on spefic unix commands? Lastly, even if that isnt possible, what would the command line to do the addition to the file look like.

  • 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. Editorial Team
    Editorial Team
    2026-05-18T20:15:25+00:00Added an answer on May 18, 2026 at 8:15 pm

    Yes, you could make a file.t target dependant on the file.c.
    file.t would get generated based on the successful completion of the test.

    It’ll be easier if you call your test function “main” and wrap it in #ifdef’s like this:

    #ifdef TEST
    int main() {
        if (test_something() == 1)
            return 0;
        else
            return 1;
    }
    #endif
    

    Of course, you can do other trickier things if you want.

    An example Makefile (using GNU Make syntax)

    all: foo.t
    
    %.t: %.c
        gcc -DTEST $< -o $@.tmp
        if ./$@.tmp ; then echo "1" > $@; rm $@.tmp ; fi
    

    However! You’ll probably be better off adopting something like CUtest (http://cutest.sourceforge.net/).

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

Sidebar

Related Questions

each source file has a function: unsigned char test(){ //return true if tests succceed
I want to process each source code file after it has been preprocessed: myprocess
We have a source XML file that has an address node, and each node
I'm trying to understand the purpose behind one header per each source file method.
I am reading a file which has source code. I need to append 2
Each time a python file is imported that contains a large quantity of static
Each year at Thanksgiving, my family has drawn names out of a hat to
Each of my clients can have many todo items and every todo item has
Each page of my site has 10 (almost) identical divs, varying only in the
Each of these variables has an integer value. But this syntax is not valid

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.