June 22: One of the things I had neglected to do was automating testing. So, I decided to do that:

  • In src/config/defaults/pcbios.h: changed #define CONSOLE_PCBIOS to #define CONSOLE_SERIAL
  • make
  • qemu -tftp . -cdrom bin/gpxe.iso -bootp /tests/arith_test.gpxe -serial stdio > result
  • Make sure the file generated gives the expected output. This can then be used to compare the output of the test script after changes have been made

After this, I started implementing the if-else branch. Since this includes defining new commands, I had to find out how it was done:

struct command if_command __command = {
.name = "if",
.exec = if_exec,
};

Also, added this in src/core/config.c

#ifdef IF_CMD
REQUIRE_OBJECT ( if_cmd );
#endif

and this in src/config/general.h

#define IF_CMD

This tells the linker to link in the code that implements the if command, present in if_cmd.c. The conditional linking is a pretty cool idea.

June 23: Implemented if-else-fi, using the stack idea. Realised, however, that I needed to also record the size of the stack for branches that are not taken. [mcb suggested that not-taken ifs should push a 0 onto the stack] This is required for nested ifs in non-executed branches; without it branches with a true condition inside a false branch will be taken:

if 0
    <statements>
    if 1
      <statements>
    fi
else
    <statements>
fi

Also fixed this problem in quoting that I hadn't considered: empty quotes '' and “” were not recognised, by adding a parameter to signify the parse function's success.

June 24: One of the suggestions I got from Stefan was to use a stack to store the arguments, instead of a linked list. I couldn't really see the connection between a stack and the argv until he mentioned that he was thinking of an array implementation. So, that would remove the need to allocate a new char* array, and also separate parsing and memory allocation. Now, since I will be using a fair number of stacks: two for the if branches, this new one and probably another for loops, I decided to see if a generic stack implementation would help. So, today's commits:

June 25: Decided on a syntax for while and for loops, and sent it to soc-mentors for suggestions. Based on the feedback, I have decided that the syntax should be:

while <cond>
do
    <statements>
done

and for the for loop:

for <var> in <string list>
do
    <statements>
done

This is similar to the bash syntax. I'm thinking that this could be implemented in a similar way to if branches: we just need another stack to store the location of the start of the loop, and some way to store the commands in the script. A suggestion on dealing with strings seemed pretty nice: define a struct string with a char * as a variable. Define functions to operate on it: strincpy, stringcat, etc. This would move the code to malloc and free strings into these functions, enabling the parsing functions to ignore the memory management details. I spent the rest of the day working on that: I had to restructure nearly all the parsing functions to use this new method. Next time, I'll start off with an idea like this instead of putting it in later. Today's commits:

June 26: Spent today going over the code and making a few last changes. Sent it out to etherboot-developers.

June 27 and 28: Didn't get much work done over the weekend. Did, however make a start on while loops. In the weekly meeting, a point that came up was how to iterate over network interfaces.

  • Have a pre-defined variable to store a count of interfaces.
  • If a success code check is possible, try to execute, say an ifstat that will return non-zero and check that
  • Look for a property of an interface, which would be unset if the interface did not exist, But, this will need references, which, while being simple to implement, would make scripts harder to read.

Navigation

* [[:start|Home]] * [[:about|About our Project]] * [[:download|Download]] * [[:screenshots|Screenshots]] * Documentation * [[:howtos|HowTo Guides]] * [[:appnotes|Application Notes]] * [[:faq:|FAQs]] * [[:doc|General Doc]] * [[:talks|Videos, Talks, and Papers]] * [[:hardwareissues|Hardware Issues]] * [[:mailinglists|Mailing lists]] * [[http://support.etherboot.org/|Bugtracker]] * [[:contributing|Contributing]] * [[:editing_permission|Wiki Edit Permission]] * [[:wiki:syntax|Wiki Syntax]] * [[:contact|Contact]] * [[:relatedlinks|Related Links]] * [[:commerciallinks|Commercial Links]] * [[:acknowledgements|Acknowledgements]] * [[:logos|Logo Art]]

QR Code
QR Code soc:2009:lynusvaz:journal:week5 (generated for current page)