summaryrefslogtreecommitdiff
path: root/410user/progs/fork_test1.c
blob: 45fa9d66443763ba179b8586069eda23a5382708 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/** @file 410user/progs/fork_test1.c
 *  @author zra
 *  @brief Tests basic functionality of fork()
 *  @public yes
 *  @for p3
 *  @covers fork
 *  @status done
 */

/* Includes */
#include <syscall.h>   /* for fork, getpid */
#include <stdlib.h>    /* for exit */
#include <stdio.h>     /* for lprintf */
#include "410_tests.h"
#include <report.h>

DEF_TEST_NAME("fork_test1:");

/* Main */
int main(int argc, char *argv[])
{
  int pid;
  
  report_start(START_CMPLT);
  pid = fork();
	
  if( pid < 0 ) {
    report_end(END_FAIL);
    exit(-1);
  }
	
  if( pid > 0 ) {
    report_fmt("parent: tid = %d", gettid());
  }
  else {
    report_fmt("child: tid = %d", gettid());
  }

  report_end(END_SUCCESS);
  exit( 1 );
}