Example #1
0
File: gax.cpp Project: jokoon/eio
gax:: gax():
    ispushed(false),
    bpk(Vec2(50,50),Vec2(200,100))
{
    cfg->SET(spiral_step);
    cfg->SET(spiral_start);

    bpk.add_bar(varname(spiral_step),&spiral_step);
    bpk.add_bar(varname(spiral_start),&spiral_start);
    bpk.add_bar(varname(how_many),&how_many);
    funs["gal"]=([this]()
    {
        lines.clear();
        float inner, arms, startmult, stepmult, spiral_resolution;
        cfg->SET(spiral_resolution);
        cfg->SET(arms);
        cfg->SET(inner);
        cfg->SET(startmult);
        cfg->SET(stepmult);

        auto
            & o = circs["o"],
            & i = circs["i"];
        float rado = wcenter.y*.9,
        radi = wcenter.y*inner;
        confpoint(o,rado,Color::Transparent,wcenter,1);
        confpoint(i,radi,Color::Transparent,wcenter,1);
        int many = how_many*arms;
        for(int i = 0; i < many; ++i)
        {
            float shift_angle = float(i)*PI*2/float(many);
//            cons_print(shift_angle);
            lines["arch"+strfy(i)]=VertexArray(LinesStrip);
            auto & thisline = lines["arch"+strfy(i)];
            for (int i=0; i< spiral_resolution; i++)
            {
                float angle = 2*PI*i/float(spiral_resolution);

                thisline.append(Vertex(Vec2(
                    wcenter.x+(spiral_start*startmult+stepmult*spiral_step*angle)
                        *cos(angle+shift_angle),
                    wcenter.y+(spiral_start*startmult+stepmult*spiral_step*angle)
                        *sin(angle+shift_angle)
                 )));
            }
        }
        lb2(lines.size());
    });
    funs["gal"]();
}
Example #2
0
File: main5.cpp Project: jokoon/eio
void vectorify(vector<Arg0>& vect, Arg0&& arg0, Args&&... more) {
	//os << std::forward<Arg0>(arg0);

	vect.push_back(strfy(std::forward<Arg0>(arg0)));
	//os << " "; // changed
	//os << ", "; // removed
	vectorify(vect, std::forward<Args>(more)...);
}
Example #3
0
File: main5.cpp Project: jokoon/eio
int main321554444()
{
    logfile lf("quads.txt");
    quadtree2 qd2(3);
	vector<vector<string>> loggy;
    qd2.insertquad({ 0.5f,0.5f }, 0, { 0.2f,0.2f }, 0, loggy);
	align(loggy);
	for (auto&a : loggy)
		lf.logw(strfy(a));

    system("PAUSE");
	return 0;
}
Example #4
0
File: main5.cpp Project: jokoon/eio
    void insertquad(Vec2 from, int depth, Vec2 remainder, size_t parent,
		vector<vector<string>> &loggy)

        /*, int maxdepth*/
    {
        int side = 1;
        float subsize = pow(0.5f, depth);
        if (remainder.x > subsize) { side += 1; remainder.x -= subsize; }
        if (remainder.y > subsize) { side += 2; remainder.y -= subsize; }

        Vec2 quadpos = from + calc_dir2(depth+2, side - 1);
        float quadsize = pow(0.5f, depth + 1);
        size_t child = 4 * parent + side;
        msgm(parent, child, "from", from, "quadpos", quadpos, "remainder", remainder, "quadsize", quadsize);
        //lf.logw(to_str(parent, child, "from", from, "quadpos", quadpos, "remainder", remainder, "quadsize", quadsize));

		vector<string> logy =
		{
			strfy(parent),
			strfy(child),
			"from " + strfy(from),
			"quadpos " + strfy(quadpos),
			"remainder " + strfy(remainder),
			"quadsize " + strfy(quadsize)
		};
		//flatten(logy);
		loggy.push_back(logy);
		
        if (depth <= maxdepth)
        {
            insertquad(
                quadpos,
				depth + 1, remainder, child, loggy);
			//depth + 1, remainder, child, lf);
        }
    }
Example #5
0
int main(int argc, char*argv[]) {
    // ████████ INITS 1 ████████
#ifndef COMMON_INITS1
    cfg.init("bedlab.cfg");
    ui2::init_ui();
    Vec2i windowsize;
    Vec2i screen_resolution = { int(VideoMode::getDesktopMode().width), int(VideoMode::getDesktopMode().height) };
    if (cfg.getvar<int>("auto_winsize")) {
        auto window_scale = cfg.getvar<Vec2>("window_scale");
        windowsize = Vec2i(scal(Vec2(screen_resolution), window_scale));
    }
    else {
        windowsize = cfg.getvar<Vec2i>("windowsize");
    }
    winsize = Vec2(windowsize);
    //UI.init_console(); // ALWAYS AFTER SO IT CAN GET WINDOW SIZE
    ui2::init_console(); // ALWAYS AFTER SO IT CAN GET WINDOW SIZE

    wincenter = 0.5f*Vec2(windowsize);
    Vec2i windowpos;
    VideoMode::getDesktopMode().height;
    if (cfg.getvar<int>("stick_left")) {
        windowpos = Vec2i(
            screen_resolution.x - windowsize.x - 10,
            screen_resolution.y - windowsize.y - 40
        );
    }
    else
        windowpos = (Vec2i(5, 25));

    sf::RenderWindow window(sf::VideoMode(windowsize.x, windowsize.y),
        "bedlab!", 7
        //,sf::ContextSettings(0, 0, 1)
    );
    window.setFramerateLimit(cfg.getvar<int>("fps_max"));
    frame_duration = 1.0f / cfg.getvar<int>("fps_max");

    window.setPosition(windowpos);

    vector<string> keys;
    auto choice = cfg.getstr("app");
    // show_keys(cfg.getstr("app"), keys);
#endif
// ████████ INITS2 ████████
#ifndef COMMON_INITS2

// we don't have a class/interface/struct with data, everything is local to this function, like a classic stack that all programs are anyway.
// Texture cursor_tx;
// if (!cursor_tx.loadFromFile(cfg.getstr("cursor")))
//     cout << "did not load cursor" << endl;
// Sprite cursor;
// cursor.setTexture(cursor_tx);
// cursor.setOrigin(3, 3);

    CircleShape cursor = mkcircle({ 0,0 }, Color::Transparent, 3, 1);
    Color background = cfg.getvar<Color>("background");
    window.setMouseCursorVisible(false);
    Vec2 mpos;
    bool leftclicked = false, rightclicked = false;

    // view and zoom
    View view, ui_view;
    ui_view = view = window.getDefaultView();
    float zoomlevel = 1;
    Vec2 mpos_abs;
    float frame_duration = 1.0f / cfg.getvar<int>("fps_max");
#endif // COMMON_INITS2
    // ████████ APP ACTUAL ████████
    {
        auto testarea = Vec2(winsize.y, winsize.y);
        auto offset = Vec2(-.5f*testarea);
        offset = { 0,0 };
        int many = 4;
        float cellsize = 0.5*testarea.x / many;
        map<Vec2i, RectangleShape> zone_rects;
    for (int i = 0; i < many + 1; ++i) {
        for (int j = 0; j < many + 1; ++j)
        {
            auto c = rgb_from_hue((float((i + j) % many)) / many);
            c.a = 128;
            auto r = mkrect2(
                Vec2(i*cellsize, j*cellsize)
                //+ offset
                ,
                Vec2(1, 1)*(cellsize - 10),
                Color::Transparent,
                5,
                false
            );
            r.setOutlineColor(c);
            //auto r_p = new RectangleShape();
            //*r_p = r;
            //grid[Vec2i(i, j)].insert(r_p);
            zone_rects[Vec2i(i, j)] = r;
            lf.logw(strfy(
                (float((i + j) % many)) / many) + " " + strfy(c)
            );
        }
    }
    }

    set<Vec2i> surround = {
        Vec2i(-1, -1) ,
        Vec2i(0, -1)  ,
        Vec2i(1, -1)  ,
        Vec2i(1, 0)   ,
        Vec2i(1, 1)   ,
        Vec2i(0, 1)   ,
        Vec2i(-1, 1)  ,
        Vec2i(-1, 0),
        Vec2i(0, 0)
    },
    active_chunks;
    float cell_size = 30;
    RectangleShape view_center = mkrect2({ 0,0 }, { 10,10 }, Color::Transparent, 1);
    RectangleShape world_center = mkrect2({ 0,0 }, { 6,6 }, Color::Red);
    //Vec2i reference_chunk = { 2,2 };
    Vec2i reference_chunk = {0,0};
    map<Vec2i, RectangleShape> chunks;
    
    for (int i = -5; i <= 5; ++i) {
        for (int j = -5; j <= 5; ++j) {
            chunks[Vec2i(i, j)] = mkrect2(cell_size*Vec2(i, j), { cell_size,cell_size }, Color::Transparent, 1);
        }
    }
    auto recenter_world = [&](Vec2i shift) {
        msgm("shifting", shift);
        world_center.move(Vec2(shift)*cell_size);
        for (auto&a : chunks) {
            a.second.move(Vec2(shift)*cell_size);
        }
        view.move(Vec2(shift)*cell_size);
        //world_center.setPosition(view.getCenter());
        world_center.move(-Vec2(shift)*cell_size);
        //for (auto&a : chunks) {
        //    a.second.setPosition(cell_size*Vec2(shift));
        //}

        for (auto&a : active_chunks) {
            chunks[a].setFillColor(Color::Transparent);
        }
        
        active_chunks.clear();
        // activate chunk surrounding the reference
        for (auto&a : surround) { 
            auto index = reference_chunk + a;
            active_chunks.insert(index);
            //chunks[index].setPosition(cell_size*Vec2(index));
            chunks[index].setFillColor(Color(255,0,0,128));
        }
    };
    recenter_world({ 0,0 });
    auto recenter_check = [&]() {
        view_center.setPosition(view.getCenter());
        //auto shift = Vec2i(2.f*view.getCenter() / (1.2f*cellsize));
        auto shift = -Vec2i(0.8f * view.getCenter() / cell_size);
        show(view.getCenter());
        //if (view.getCenter().x > cell_size*1.2f) reference_chunk.x -= 1;
        //if (view.getCenter().y > cell_size*1.2f) reference_chunk.y -= 1;
        //if (view.getCenter().x < -cell_size*1.2f) reference_chunk.x += 1;
        //if (view.getCenter().y < -cell_size*1.2f) reference_chunk.y += 1;

        //msg("recenter triggered!");
        //reposition_chunks();
        //reference_chunk = Vec2i();
        if (shift != Vec2i{0, 0}) recenter_world(shift);
        reference_chunk -= shift;
    };
    // ████████ callbacks ████████
    bool panning = false;
    Vec2 previous_mouse_pos;
    view.setCenter({ 0,0 });
    //view.sets
#ifndef LOOP_LAMBDAS
    draw = [&]() {
        window.setView(view);
        //////////////// OBJECTS THAT CAN ZOOMED ////////////////
        window.draw(glob_vert_single);
        for (auto&a : glob_pts)window.draw(a);
        for (auto&a : glob_rects)window.draw(a);
        for (auto&a : glob_vert)window.draw(a);
        for (auto&a : glob_texts)window.draw(a);
        //////////////// OBJECTS THAT CAN ZOOMED ////////////////
        //for (auto&a : zone_rects) window.draw(a.second);
        for (auto&a : chunks) window.draw(a.second);

        window.draw(view_center);
        window.draw(world_center);

        // UI draw, AFTER ui view and BEFORE other draw
        window.setView(ui_view);
        //////////////// OBJECTS THAT CANNOT ZOOMED, MEANING UI ////////////////
        //br.drawwithtext(window);
        ui2::draw(window);
        //UI.draw(window);
        window.draw(cursor);
    };
    update = [&]() {
        recenter_check();
    };
    treatkeyevent = [&](Keyboard::Key k) {
        switch (k)
        {
        case Keyboard::E:
            break;
        case Keyboard::I:

            break;
        case Keyboard::Q:
            break;
        case Keyboard::BackSpace:
            glob_pts.clear();
            glob_texts.clear();
            glob_rects.clear();
            glob_vert.clear();
            break;

        case Keyboard::Space:
            break;

        case Keyboard::S:
            screenshot(window);
            break;
        case Keyboard::Num1:
        case Keyboard::Num2:
        case Keyboard::Num3:
        case Keyboard::Num4:
        case Keyboard::Num5:
            break;
        }
    };
    mousemoved = [&](Vec2 pos) {
        cursor.setPosition(pos);
        if (leftclicked);
        if (panning) {
            view.move((previous_mouse_pos - pos));
        }
        previous_mouse_pos = pos;
    };
    mouseclick = [&](sf::Mouse::Button button) {
        if (button == Mouse::Button::Left) leftclicked = true;
        if (button == Mouse::Button::Right) rightclicked = true;
        if (button == Mouse::Button::Left) {
        };
        panning = leftclicked;

    };
    mouserelease = [&](sf::Mouse::Button button) {
        if (button == Mouse::Button::Left) leftclicked = false;
        if (button == Mouse::Button::Right) rightclicked = false;
        if (button == Mouse::Button::Left) {
        }
        panning = leftclicked;

    };
    loop = [&]() {
        while (window.isOpen())
        {
            sf::Event event;
            while (window.pollEvent(event))
            {
                switch (event.type)
                {
                case sf::Event::KeyPressed:
                    if (event.key.code == sf::Keyboard::Escape)
                        window.close();
                    treatkeyevent(event.key.code);
                    break;
                case sf::Event::Closed:
                    window.close();
                    break;
                case sf::Event::MouseButtonPressed:
                    mouseclick(event.mouseButton.button);
                    break;
                case sf::Event::MouseButtonReleased:
                    mouserelease(event.mouseButton.button);
                    break;
                case sf::Event::MouseMoved:
                    mpos = Vec2(event.mouseMove.x, event.mouseMove.y);
                    mpos_abs = window.mapPixelToCoords(Vec2i(mpos), view);
                    mousemoved(mpos);
                    break;
                default:
                    treatotherevent(event);
                    break;
                }
            }

            window.clear(background);
            update();
            draw();
            window.display();
        }
    };
    treatotherevent = [&](Event&e) {
        if (e.type == Event::MouseWheelMoved && e.mouseWheel.delta)
        {
            mpos_abs = window.mapPixelToCoords(Vec2i(mpos), view);

            //view = window.getView();
            if (e.mouseWheel.delta < 0)
            {
                zoomlevel *= 2.f;
                view.setSize(view.getSize()*2.f);
                view.setCenter(interp(mpos_abs, view.getCenter(), 2.f));
                //view.setCenter(interp(mpos_abs, view.getCenter(), 2.f));
            }
            if (e.mouseWheel.delta > 0)
            {
                zoomlevel *= 0.5;
                view.setSize(view.getSize()*.5f);
                view.setCenter(.5f*(view.getCenter() + mpos_abs));
                //view.setCenter(.5f*(view.getCenter() + mpos_abs));
            }
            window.setView(view);
        }
    };
#endif // LOOP_LAMBDAS

    loop();
}
Example #6
0
int main (int argc, char **argv)
{
  int nbytes;
  
  /* Test cases. */

  char cmd1[] = "./t1 " strfy(T_MAKEIO);  /* Exits EXECFAILSTATUS */
  char cmd2[] = "./t1 &";
  char cmd3[] = "./t1 " strfy(T_WRITEFIFO) " &"; /* Write to fifo. */

  int result, pid, nerrors, rs, redirok, io[3], i, fd, wasnonblock;
  pthread_t thread;
  char buffer[4];
  struct sigaction act;

  test_set = "T2";
  nerrors = 0;

  /* Disable standard streams if not redirecting. */

  sysfatal ((noio[0] = open ("/dev/null", O_WRONLY)) <0);
  sysfatal ((noio[1] = open ("/dev/null", O_WRONLY)) <0);
  sysfatal ((noio[2] = open ("/dev/null", O_WRONLY)) <0);

  /* Check  redirection

     Redirect subprocess' stdandard input and output to a pipe.
     Write a predefined watchword and wait for a specific countersign.
     If subprocess does not read from the pipe or does not write back,
     assume test failure. */

  /* Create the pipe. */

  rs = pipe (pipefd);
  sysfatal (rs<0);

  /* Use a new thread to write to the pipe so that caller never blocks.
     This is probably unecessary but we do it anyway. */

  pthread_create (&thread, NULL, writepipe, NULL);

  io[0] = pipefd[0];		/* Redirect standard input.  */
  io[1] = pipefd[1];		/* Redirect standard output. */
  io[2] = 2;	                /* Dont touch standard error.*/

  /* Call runcmd. */

  pid = try_runcmd (cmd1, &result, io);   

  /* printf ("  Checking...\n"); */

  /* Read subprocess reply. If subprocess is not reading from the pipe
     (redirected standard input) it will block and timeout without having
     received the watchword, thereby sending an incorrect ack. A correct
     countersign is sent, otherwise. */

  buffer[0]='\0';		
  nbytes = read (pipefd[0], buffer, T_TOKENSIZE);
  sysfatal (nbytes<0);
  buffer[3]=0;

  /* Check countersign.*/

  if (!strcmp(buffer,T_READTHIS)) /* Subprocess answered correctly. */
    redirok=1;
  else				   /* Subprocess must have timed-out. */
    redirok=0;

  nerrors += check ("whether stdin/stdout are redirected correctly", redirok);

  /* Check IS_NONBLOCK and runcmd_onexit.

     Set up a SIGCHLD handler andm ake a nonblocking call. Check IS_NONBLOCK.
     Check if the handler has been called. 
 */

  runcmd_onexit = onexit;
  pid = try_runcmd (cmd2, &result, NULL);   

  /* printf ("Checking...\n"); */

  nerrors += check ("whether nonblock is correctly reported", 
		    IS_NONBLOCK(result));

  for (i=-0; (i<3) && (!onexit_called); i++) /* Wait a resonable time. */
    sleep(1);

  nerrors += check ("whether runcmd_onexit is called when requested", 
		    onexit_called);
 


  /* Check parallel execution. 
     
     Try to communicate with subprocess through a named pipe (FIFO).
     Send a watchword and checks the countersign. If client is not running in
     parallel, caller will block. Use timeouts to detect this case. */

  /* Create a fifo. */

  unlink (T_FIFONAME);
  rs = mkfifo (T_FIFONAME, 0600);
  sysfatal (rs<0);

  buffer[0]='\0';		
  /* io[0]=0; io[1]=1; io[2]=2; */

  /* Set a time out alarm. */

  rs = sigaction (SIGALRM, NULL, &act);
  sysfatal (rs<0);
  act.sa_handler = giveup;
  rs = sigaction (SIGALRM, &act, NULL);
  sysfatal (rs<0);

  /* Make a nonblocking call. Probe probram will try to open the
     fifo to read from it. If subprocess is not running in parallel,
     it will block since caller itself has not opened the fifo as yet,
     caise the caller to block in a deadlock. Only time out releases
     caller. */

  expired = 0;
  alarm (TIMEOUT);
  pid = try_runcmd (cmd3, &result, io);
  alarm (0);

  /* Now caller opens the fifo and reads from it. Had a faulty (nonparallel)
     subprocess been stuck, it would not proceed and write into the fifo. */

  fd = open (T_FIFONAME, O_RDONLY);
  sysfatal (fd<0);

  /* Caller may read from fifo now. */

  nbytes = read (fd, buffer, T_TOKENSIZE);
  sysfatal (nbytes<0);
  buffer[nbytes]='\0';

  /* Check the countersigh. */

  wasnonblock = 0;
  if (!strcmp(buffer, T_READTHIS))
    wasnonblock=1;
  
  /* Result is ok if countersigh is correct and caller has not timedout. */

  /* printf ("Checking...\n"); */

  nerrors += check ("nonblock mode execs in parallel", 
  		    (!expired) && (wasnonblock));
  /* Cleanup. */

  unlink (T_FIFONAME);

  pid = pid;			/* Avoid gcc complaints. */


  return nerrors;

}
Example #7
0
File: main5.cpp Project: jokoon/eio
vector<string> to_vector2(Args&&... args) {
	//std::stringstream ss;
	vector<string> vect = { strfy(args)... };
	//vectorify(vect, std::forward<Args>(args)...);
	return vect;
}
Example #8
0
File: main5.cpp Project: jokoon/eio
void vectorify(vector<Arg0>& vect, Arg0&& arg0) {
	//os << arg0 << std::endl;// changed
	//os << arg0;
	vect.push_back(strfy(arg0));
}
Example #9
0
File: game.cpp Project: jokoon/eio
void game :: init(){
    pause_drawing=false;
    glines = VertexArray(Lines);
    conf.init("conf.cfg");
    cfg=&conf;
    fps_coeff = 1.f/cfg->getfloat("timestep");

    //srand((unsigned)time(0));
    window.setKeyRepeatEnabled(false);
    wincenter.x=window.getSize().x/2;
    wincenter.y=window.getSize().y/2;
    winsize.x=window.getSize().x;
    winsize.y=window.getSize().y;
    window.setFramerateLimit(fps_coeff);

    if(cfg->getint("stick_left"))
    {
        Vec2i screen_resolution;
        cfg->SET(screen_resolution);
#ifdef __APPLE__
        screen_resolution=Vec2i(1280,800);
#endif
        Vec2i windowpos(screen_resolution.x - winsize.x-10,25);
        cout << strfy(screen_resolution) << endl;
        cout << strfy(windowpos) << endl;
        window.setPosition(windowpos);
    }
    else
        window.setPosition(Vec2i(5,25));


    {
        Vec2 cons_view_size;
        cfg->SET(cons_view_size);
        console_view.setSize(Vec2(cons_view_size.x*wsize.x,cons_view_size.y*wsize.y));
        fixedview = window.getDefaultView();
        mainview=fixedview;
    }
    wsize = winsize;
    wcenter = wincenter;
    float window_coeff = conf.getfloat("window_coeff");
    if(window_coeff!=1.0)
    {
        Vec2u resized(winsize.x*window_coeff,winsize.y*window_coeff);
        window.setSize(resized);
    }
    bg = cfg->getcolor("background");
    string path="yes/";
#ifdef __APPLE__
    path = resourcePath()+path;
#endif
    if(!cursor_tx.loadFromFile(path+"cursor4.png")) cout << "did not load cursor" << endl;
    cursor.setTexture(cursor_tx);
    cursor.setOrigin(3,3);
    window.setMouseCursorVisible(false);

    confpoint(c1,3,Color::Green);
    confpoint(c2,3,Color::Red);

    // fonts and f*****g globals
    init_font();
    font1 = &ft;
    font2 = &ft2;
    charsize=chsz;
    charsize2=chsz2;

    // console
    console = new sfconsole;
    console->numlines=conf.getint("numlines");
    console->init();
    cons=console;
    draw_console = true;

    labs=new labels;
    labs->pos=Vec2(15,winsize.y-30);
    lbs=&(labs->strings);


    win=&window;

    add_symbol_to_lambdas();

    if(cfg->getint("use_menu"))
    {
        menu_loop();
    }
    else
    {
        init_gameobj();
        loop();
    }
}
Example #10
0
int main (int argc, char **argv)
{
  /* int result, i; */

  /* Test cases. */

  /* char cmd1[] = "ls runcmd.c" ;     /\* File does exist. *\/ */
  /* char cmd2[] = "./segfault";       /\* Abnormal termination. *\/ */
  /* char cmd3[] = "ls nosuchfile";    /\* File does not exist. *\/ */
  /* char cmd4[] = "./io";  	         /\* Test IO redirection. *\/ */
  /* char cmd5[] = "./nosuchfile";     /\* Exec failed. *\/ */
  /* char cmd6[] = "./delay &";        /\* Test nonblock. *\/ */

  #define _strfy(val) # val
  #define  strfy(val) _strfy(val)

  char cmd1[] = "./t1" ;                          /* Exits 10. */
  char cmd2[] = "./t1 11";                        /* Exits 11. */
  char cmd3[] = "./t1 15";                        /* Segaful. */
  char cmd4[] = "./nosuchfile";                   /* Not found. */
  char cmd5[] = "./t1 " strfy(EXECFAILSTATUS);    /* Exits EXECFAILSTATUS */

  /* int io[3], io2[3], pid, rpid, nerrors; */
  int result, i, pid, io[3], rpid, nerrors;
  FILE *fp;

  nerrors = 0;


  /* Disable standard streams if not redirecting. */

  sysfatal ((noio[0] = open ("/dev/null", O_WRONLY)) <0);
  sysfatal ((noio[1] = open ("/dev/null", O_WRONLY)) <0);
  sysfatal ((noio[2] = open ("/dev/null", O_WRONLY)) <0);

  /* io[0]=1; io[1]=1; io[2]=2; */

  /* Check  */

  pid = try_runcmd (cmd3, &result, NULL);   /* Normal, success. */
  printf ("  Checking...\n");

  nerrors += check ("abnormal termination is correctly reported",
		    (!IS_NORMTERM(result)) &&
		    (EXITSTATUS(result) == 0));

  /* Check */

  pid = try_runcmd (cmd1, &result, NULL);   /* Normal, success. */
  printf ("  Checking...\n");

  fp = fopen ("t1.log", "r");
  sysfatal (!fp);
  fscanf (fp, "%d", &rpid);

  nerrors += check ("normal termination is correctly reported",
		    IS_NORMTERM(result));

  nerrors += check ("pid is correctly returned on success",
		    (IS_NORMTERM(result)) &&
		    (pid == rpid));

  nerrors += check ("exit status is correctly reported on sucess",
		    (IS_NORMTERM(result)) &&
		    (EXITSTATUS(result) == 10));

  nerrors += check ("exec success if correctly reported",
		    (IS_NORMTERM(result)) &&
		    (IS_EXECOK(result)));


  fclose (fp);
  unlink ("t1.log");

  /* Check  */

  pid = try_runcmd (cmd2, &result, NULL);   /* Normal, success. */
  printf ("  Checking...\n");

  nerrors += check ("command line arguments are correctly read", EXITSTATUS(result) == 11);

  /* Check */

  pid = try_runcmd (cmd4, &result, NULL);   /* Normal, success. */
  printf ("  Checking...\n");

  nerrors += check ("exec failure is correctly reported (a)",
		    (!IS_EXECOK(result)) &&
		    (EXITSTATUS(result) == EXECFAILSTATUS));

  /* Check */

  pid = try_runcmd (cmd5, &result, NULL);   /* Normal, success. */
  printf ("  Checking...\n");

  nerrors += check ("exec failure is not reported on sucess (b)",
		    (IS_EXECOK(result)) &&
		    (EXITSTATUS(result) == EXECFAILSTATUS));

  /* Politeness. */

  for (i=0; i<3; i++)
    {
      close (noio[i]);
      close (io[i]);
    }


  return nerrors;



  /* Test redirection. */

  /* sysfatal ((fd = open ("in.txt", O_CREAT | O_TRUNC | O_RDWR,  S_IRUSR | S_IWUSR)) <0); */
  /* write (fd, "a", 1); */
  /* sysfatal(close(fd)<0); */

  /* sysfatal ((io2[0] = open ("in.txt", O_RDONLY)) <0); */
  /* sysfatal ((io2[1] = open ("out.txt", O_CREAT | O_TRUNC | O_RDWR,  S_IRUSR | S_IWUSR)) <0); */
  /* sysfatal ((io2[2] = open ("err.txt", O_CREAT | O_TRUNC | O_RDWR,  S_IRUSR | S_IWUSR)) <0); */


  /* result +=tryrun (&tc[3], io2, 1, 0, EXECYES);   /\* Normal, success. *\/ */

  /* /\* Test nonblock. *\/ */

  /* result +=tryrun (&tc[5], io2, 1, 0, EXECFAIL);   /\* Normal, success. *\/ */

  /* /\* Test whether exec failed. *\/ */

  /* result +=tryrun (&tc[5], io, 1, 0, EXECYES);   /\* Normal, success. *\/ */

  /* /\* Polite clean-up before leaving. *\/ */

  /* return result; */
}