mirror of
https://github.com/Alvin-Zilverstand/bob16.git
synced 2026-11-23 21:22:59 +01:00
e
This commit is contained in:
1 parent
78dd619293
commit
6dc841f956
109 files changed
+18192
-1907
No files matched your search
@@ -381,3 +381,69 @@ Added `<stddef.h>` with width-matched `size_t`/`ptrdiff_t` and `NULL`. `sizeof`
|
||||
Host C now supports typed function-pointer declarations and calls, including local/file-scope pointers, nested pointer parameters, function-address relocations, copying, and parenthesized indirect calls. Empty `()` signatures accept unspecified call arguments; typed signatures enforce argument count and compatibility. B16/B32 positive and negative regressions cover these behaviors, including invalid casts between function and object pointers. Full suite: CPU 194, OS/compiler 1,793, console 28.
|
||||
|
||||
Native bob32 application workflow: the RAM filesystem packs eight file slots into 4,096 words, allowing validated B32K v2 images larger than 511 words. `import32 HOST_PATH NAME` stores an image, `run NAME` or `run32 NAME` executes it from guest RAM, and B32S v2 snapshots preserve it; B32S v1 fixed-slot snapshots convert on restore. Integration tests import a 629-word image, execute it through both guest-name commands, save/restore, and execute again. Failure coverage checks missing, invalid and truncated images, storage-capacity exhaustion, checksum corruption and sparse-memory allocation failure. The expanded bob32 kernel now runs at `0x10000..0x1D115`, with native applications starting at `0x20000`. Resident compiler diagnostics include token context with the existing source location. Full suite: CPU 203, OS/compiler 1,813, console 28.
|
||||
|
||||
Native apps now access the bob32 RAM filesystem through version 1 of the `bob_fs.h` service API: list files and metadata, read/write text, delete, and query basic system information. Apps `echo`, `ls`, `cat`, `sysinfo`, and `notes` compile as B32K images and run in the emulator; the notes integration creates a file, snapshots it, restores in a second process, reads it, and deletes it. Argument parsing preserves empty arguments and stops at the input terminator. Full suite: CPU 203, OS/compiler 1,874, console 28.
|
||||
|
||||
Added a version 1 `bob_gfx.h` cell-framebuffer API with resolution queries, colors, pixels, filled rectangles, lines, text, transparent bitmap-cell blitting, clearing, presentation and clean exit. The 80x25 terminal backend is decoupled from drawing calls. `bob_event.h` adds blocking four-word character/special-key events, with release/mouse types reserved. `apps/graphics_demo.c` draws the canvas, waits for a test key event, exits graphics mode and prints `bob!`. Full suite: CPU 203, OS/compiler 1,880, console 28.
|
||||
|
||||
Added a reusable `bob_gui.h` window-frame helper and `apps/gui_demo.c`, a small two-window desktop prototype with title bars, active-window focus colors, Tab focus switching, Backspace editing, and character routing to the focused window. The Windows console event backend now reports key-up, mouse movement, and button transitions in addition to key-down/character events; the GUI draws a `+` cursor and mouse clicks select a window. Redirected input remains character based. Escape exits graphics mode and returns to the shell with `bob!`. End-to-end tests cover rendering, keyboard focus/routing, and clean return. Full suite: CPU 203, OS/compiler 1,888, console 28.
|
||||
|
||||
Extracted host input record decoding into a deterministic helper and added CPU tests for character presses/releases, normalized arrow keys, mouse coordinates, button press/release, and duplicate button-state filtering. Full suite: CPU 210, OS/compiler 1,888, console 28.
|
||||
|
||||
Added reusable GUI rectangle hit-testing and title-bar drag helpers with screen-edge clamping. The desktop prototype now supports mouse dragging while retaining click focus and keyboard focus. Window frames and title strips are visually distinct. A native bob32 fixture tests hit bounds, drag offsets, movement, clamping and drag release. Full suite: CPU 210, OS/compiler 1,892, console 28.
|
||||
|
||||
Added reusable GUI button draw and event helpers with hover, pressed, and left-click activation states; labels clip to the button interior. The desktop demo includes an “Open Window B” button that moves keyboard focus. Native bob32 tests cover hover, left press, inside-release activation, and release outside without activation. Full suite: CPU 210, OS/compiler 1,892, console 28.
|
||||
|
||||
Added a reusable single-line GUI text field with mouse caret placement, insertion, Backspace/Delete, Left/Right/Home/End, visible caret drawing, and horizontal scrolling. The demo now includes an editable field; the native bob32 fixture checks insertion, navigation, deletion, blur, and scroll offset. Full suite: CPU 210, OS/compiler 1,892, console 28.
|
||||
|
||||
Added reusable z-order operations for packed window rectangles: topmost hit-testing and raising a clicked window. The GUI demo draws bottom-to-top and sends pointer/widget events only to the visible top window, so overlapping windows have consistent focus and control behavior. Native bob32 fixture checks overlap selection, order changes, invalid IDs, and outside hits. Full suite: CPU 210, OS/compiler 1,892, console 28.
|
||||
|
||||
Connected the GUI demo's second window to `bob_fs.h`: it lists guest files, allows mouse or n/p row selection, and previews the selected text file. The emulator integration test creates `gui.txt` with a unique preview marker, selects it with the keyboard, verifies that exact content is rendered, and checks clean exit. Full suite: CPU 210, OS/compiler 1,894, console 28.
|
||||
|
||||
Added line-aware scrolling to the file preview using Up/Down and u/d, with scroll reset on file selection. The GUI integration test creates a long text file whose unique marker begins beyond the initial six preview rows, navigates to it, scrolls down, and verifies the marker is rendered. Full suite: CPU 210, OS/compiler 1,896, console 28.
|
||||
|
||||
Added an on-screen Yes/Cancel confirmation panel for text-file deletion, with mouse buttons and keyboard y/n support. Deletion is restricted to text files. The GUI clears stale preview/selection state after filesystem changes. Integration tests verify cancellation preserves the file, confirmation deletes it, and guest `cat` cannot read it afterward. Full suite: CPU 210, OS/compiler 1,902, console 28.
|
||||
|
||||
Expanded the GUI editor window with filename and text fields, a Save button, and Ctrl+S; Tab cycles through filename, text, and browser focus without stealing normal typed characters. Saved text files appear in the browser. Integration tests save `new.txt` from the GUI, save the filesystem snapshot, restore in a fresh emulator process, and read the file with `cat`. Full suite: OS/compiler 1,907 checks.
|
||||
|
||||
Added version 1 process service operation 6 and `bob_process.h` for launching stored kind-3 native apps with quoted arguments. Nested apps run in the shared address range while the emulator snapshots/restores the suspended app's sparse memory, CPU state, arguments, and graphics buffer; nesting is bounded at eight frames. Added a native launcher that lists apps and passes arguments. Integration launches `echo` through `launcher`, verifies its quoted argument and child exit status, snapshots both apps, restores them in a new process, and launches the child again. Full build: CPU 210, OS/compiler 1,920, console 28.
|
||||
|
||||
Expanded the protected bob32 packed filesystem from 4,096 to 8,192 words at `0x1E000..0x1FFFF`, preserving the 0x20000 native-app boundary. B32S v3 stores the larger payload; v1 fixed-slot and v2 packed snapshots remain readable, and bob16 B16S layout is unchanged. Native launch regression imports launcher, echo, and notes with the starter source, runs notes as a child to create a file, then restores the apps and data in a new process. Full build: CPU 211, OS/compiler 1,926, console 28.
|
||||
|
||||
Added `bob_memory.h`, a caller-owned word arena that fits bobcc's current C subset. Apps allocate contiguous ranges from their own integer buffer, check used/remaining words, and reset for reuse; invalid and exhausted requests return null, without reserving global OS memory. A compiled native app checks bounds, writes through returned pointers, verifies exhaustion, resets, and reallocates. Full build: CPU 211, OS/compiler 1,930, console 28.
|
||||
|
||||
Added version 1 OS time operation 7 and `bob_time.h`. Native apps can query UTC seconds since the Unix epoch as low/high 32-bit words, with request-range and capacity validation in the emulator. A compiled and imported native app verifies a plausible current timestamp through the service. Full build: CPU 211, OS/compiler 1,934, console 28.
|
||||
|
||||
Extended the native filesystem API with word-preserving binary reads/writes for bob16 and bob32 program kinds. The emulator rejects other write kinds, validates app buffers and sizes, and keeps native B32K app storage behind the existing validated import flow. API request wrappers now provide all seven initialized service words. A native app writes signed/high-bit words, verifies kind/size and short-buffer errors, saves a B32S snapshot, restores in a fresh process, reads the same words, and deletes the file. Full build: CPU 211, OS/compiler 1,942, console 28.
|
||||
|
||||
Added `bob_gfx_blit_color` for transparent cell bitmaps with per-cell 16-color foregrounds. Cell values encode an ASCII glyph and color; invalid values reject the request before drawing. A compiled native app verifies rejection, renders a multicolor bitmap through the emulator, checks visible output, and returns to the shell. Full build: CPU 211, OS/compiler 1,948, console 28.
|
||||
|
||||
Added an application-launcher panel to `gui_demo`: it lists stored kind-3 apps, supports keyboard and mouse selection, runs the chosen app through `bob_process.h`, then redraws the desktop with the child's exit code. Integration test drives the GUI with Tab, opens the launcher, starts a stored child returning 7, verifies its output/status, and exits cleanly. Full build: CPU 211, OS/compiler 1,955, console 28.
|
||||
|
||||
Added `bob_native.h` as an opt-in umbrella for common native APIs: core calls, strings, caller-managed memory, files, processes, time, and events. Graphics/GUI remain separate includes to keep those optional. A native bobcc fixture includes only the umbrella, exercises strings, arena allocation, text filesystem operations and UTC time, then runs inside bob32. Full build: CPU 211, OS/compiler 1,959, console 28.
|
||||
|
||||
Extended `notes` with an explicit `edit` replacement command and `add` line-append workflow, length checks, and protection against treating binary/program files as notes. Added `bob_file_kind(name)` to the native filesystem API so apps can query file metadata without scanning every slot. Removed the notes app's duplicate general-purpose string-library dependency; `launcher`, `echo`, `notes`, and the starter source still fit together in the 8,192-word filesystem. Integration edits and appends a note, saves/restores B32S in a fresh process, verifies the content, and confirms `notes` refuses to delete its own executable. Full build: CPU 211, OS/compiler 1,960, console 28.
|
||||
|
||||
Added an opt-in `bob_font.h` 5x7 bitmap font renderer. `bob_gfx_bitmap_text` maps lowercase to uppercase, supports A-Z, digits, space and common punctuation, substitutes `?` for unsupported characters, and rasterizes glyphs as per-color canvas pixels. A native app renders `BOB!`; integration checks its exact raster row and clean return to the shell. Full build: CPU 211, OS/compiler 1,965, console 28.
|
||||
|
||||
Added version 1 event operation 28 and `bob_event_poll`, which peeks Windows console records without blocking and decodes the same key/mouse events as `bob_event_wait`. Empty/redirected input returns 0 and leaves redirected characters available to the blocking API. A native app polls, then waits for the next redirected key and verifies its event type/value. Full build: CPU 211, OS/compiler 1,969, console 28.
|
||||
|
||||
Integrated the 5x7 bitmap font in `gui_demo` through a keyboard/mouse help overlay. Press `?` to view a large bitmap `HELP` heading and shortcuts; Escape or Close returns to the desktop. Modal overlays clear the canvas behind them while retaining the status row. Native UI integration checks the rendered glyph row and close behavior. Full build: CPU 211, OS/compiler 1,973, console 28.
|
||||
|
||||
Expanded `bob_gui.h` with a reusable multiline text area that supports caret placement, insertion, deletion, Home/End and arrow movement, vertical scrolling, and horizontal scrolling for long lines. The GUI editor now loads a selected text file with `e` and saves it with Ctrl+S; the text area handles up to 511 characters. Native widget tests cover newline editing and cursor movement, while an end-to-end test edits a two-line file and verifies the saved newline/content through `cat`. Full build: CPU 211, OS/compiler 1,980, console 28.
|
||||
|
||||
Extended event version 1 with signed Windows mouse-wheel deltas. The GUI file browser uses wheel direction to change selection over the file list or scroll the selected preview over its text; synthetic event-decoder checks cover upward and downward deltas. Full build: CPU 213, OS/compiler 1,980, console 28.
|
||||
|
||||
The reusable multiline text area now responds to wheel events over its bounds, moving the viewport while leaving the byte cursor in place. The GUI routes wheel input to the editor when that window is frontmost, and widget checks verify scrolling at both content boundaries. The full suite remains green: CPU 213, OS/compiler 1,980, console 28.
|
||||
|
||||
Added reusable popup-menu drawing and event helpers with fixed-stride labels, keyboard up/down selection, Enter activation, Escape close, and mouse hover/click behavior. Window B opens the File menu with `m` or from its title area; actions open the selected text file, start delete confirmation, or close the menu. Corrected the bare bob32 guest test helper to execute under `kernel32.b32`, so success-marker assertions now verify actual OS-launched apps rather than a kernel boot lacking OS services. Added screen-clamped popup placement and anchor it to Window B so it follows dragging. Full build: CPU 213, OS/compiler 1,991, console 28.
|
||||
|
||||
Added a `history` shell builtin to print recent commands with their session order. Up/Down browsing still retains four entries in the explicitly reserved history region; tests cover listing, invalid arguments and interactive recall. Raised the long bob32 shell workflow's execution budget to 60 million cycles after the expanded kernel path exceeded its previous 50-million ceiling. Full build: CPU 213, OS/compiler 1,996, console 28.
|
||||
|
||||
Added `bob_event_queue.h`, an optional caller-owned FIFO for version-1 input events. Tests verify empty/full behavior, FIFO ordering, wraparound after popping and pushing, and invalid capacity; the shared `bob_native.h` umbrella includes it. Full build: CPU 213, OS/compiler 1,996, console 28.
|
||||
|
||||
Adjusted native `cat` to preserve a file's existing trailing newline instead of adding an extra blank line, while still separating nonempty unterminated file content from the shell exit status. End-to-end tests cover trailing-newline and empty files. Full build: CPU 213, OS/compiler 2,000, console 28.
|
||||
|
||||
Added the version 1 `bob_system.h` capability query for the cell framebuffer dimensions and keyboard/mouse availability. `sysinfo` now reports these capabilities along with memory and filesystem usage on readable, single-line entries; its integration test checks the reported API version, framebuffer, dimensions and keyboard. Full build: CPU 213, OS/compiler 1,985, console 28.
|
||||
|
||||
Added `bob_wm.h` as a reusable bob32 window manager for fixed-capacity window lifecycle, focus, stacking, hit testing, clamped title-bar dragging, input routing, and dirty redraw ordering. The GUI demo now uses manager IDs for its editor and file browser, redraws dirty windows in stack order, and no longer tracks focus, stacking, or drag state itself. Synthetic manager tests cover overlap, background-window focusing, local coordinates, edge drags, redraw order, hide/destroy, and slot reuse. The GUI integration fixture still checks preview scrolling, delete cancellation/confirmation, and save behavior. Verified separately against fresh emulator builds: CPU 213, OS/compiler 2,000, native console 28.
|
||||
+2676
File diff suppressed because it is too large.
Load diff
+59
-23
@@ -38,6 +38,27 @@ static void bad_image(const char *executable,const unsigned char *bytes,size_t l
|
||||
char command[4096];snprintf(command,sizeof(command),"\"%s\" --load-fixture build/cpu-bad.b32 > build/cpu-bad.out 2>&1",executable);
|
||||
verify(system(command)!=0,"invalid wide image rejected");
|
||||
}
|
||||
static void input_event_decoding(void) {
|
||||
unsigned buttons=0;int type=0,value=0,x=0,y=0;
|
||||
verify(terminalEventDecode(1,1,'a',65,0,0,0,&buttons,&type,&value,&x,&y) &&
|
||||
type==OS_EVENT_CHAR&&value=='a',"event decoder returns typed characters");
|
||||
verify(terminalEventDecode(1,0,'a',65,0,0,0,&buttons,&type,&value,&x,&y) &&
|
||||
type==OS_EVENT_KEY_UP&&value=='a',"event decoder returns character key releases");
|
||||
verify(terminalEventDecode(1,1,0,38,0,0,0,&buttons,&type,&value,&x,&y) &&
|
||||
type==OS_EVENT_KEY_DOWN&&value==256,"event decoder normalizes special keys");
|
||||
verify(terminalEventDecode(2,1,0,0,17,9,0,&buttons,&type,&value,&x,&y) &&
|
||||
type==OS_EVENT_MOUSE_MOVE&&x==17&&y==9,"event decoder reports mouse coordinates");
|
||||
verify(terminalEventDecode(2,0,0,0,17,9,1,&buttons,&type,&value,&x,&y) &&
|
||||
type==OS_EVENT_MOUSE_BUTTON_DOWN&&value==1&&buttons==1,"event decoder reports button press");
|
||||
verify(!terminalEventDecode(2,0,0,0,17,9,1,&buttons,&type,&value,&x,&y),
|
||||
"event decoder filters unchanged mouse button state");
|
||||
verify(terminalEventDecode(2,0,0,0,18,9,0,&buttons,&type,&value,&x,&y) &&
|
||||
type==OS_EVENT_MOUSE_BUTTON_UP&&value==0&&buttons==0,"event decoder reports button release");
|
||||
verify(terminalEventDecode(2,0,4,0,18,9,120u<<16,&buttons,&type,&value,&x,&y) &&
|
||||
type==OS_EVENT_MOUSE_WHEEL&&value==120&&x==18&&y==9,"event decoder reports upward mouse-wheel delta");
|
||||
verify(terminalEventDecode(2,0,4,0,18,9,0xff880000u,&buttons,&type,&value,&x,&y) &&
|
||||
type==OS_EVENT_MOUSE_WHEEL&&value==-120,"event decoder reports downward mouse-wheel delta");
|
||||
}
|
||||
int main(int argc,char **argv) {
|
||||
if(argc>1 && !strcmp(argv[1],"--emulator"))return bob_emulator_main(argc-1,argv+1);
|
||||
if(argc==3 && !strcmp(argv[1],"--load-fixture")){bootImage(argv[2]);return 0;}
|
||||
@@ -54,6 +75,7 @@ int main(int argc,char **argv) {
|
||||
memoryWrite(0x10003,'b');memoryWrite(0x10004,'!');step(0xf200);
|
||||
return cpu.ir==0xf200?0:1;
|
||||
}
|
||||
input_event_decoding();
|
||||
for(unsigned bits=1;bits<=16;bits++) {
|
||||
verify(sext((int16_t)((1u<<bits)-1),bits)==-1,"negative immediate");
|
||||
verify(sext((int16_t)((1u<<(bits-1))-1),bits)==(int)((1u<<(bits-1))-1),"positive immediate");
|
||||
@@ -76,49 +98,63 @@ int main(int argc,char **argv) {
|
||||
cpu.regFile[0]=0x1000300;cpu.regFile[1]=0;step(0xf700);
|
||||
verify(cpu.regFile[0]==-3,"wide storage trap rejects truncated descriptor address");
|
||||
ram.memory[0x400]='b';ram.memory[0x401]='o';ram.memory[0x402]='b';ram.memory[0x403]='!';
|
||||
ram.memory[0x500]=1;ram.memory[0x510]=1;ram.memory[0x520]=1;ram.memory[0xf000]=0x12345678;ram.memory[0xf001]=0;
|
||||
ram.memory[0x500]=1;ram.memory[0x510]=1;ram.memory[0x520]=1;memoryWrite(WIDE_FILE_BASE,0x12345678);memoryWrite(WIDE_FILE_BASE+1,0);
|
||||
const char *source_name="bobs.c",*source_text="bob!";
|
||||
for(unsigned i=0;source_name[i];i++)ram.memory[0x418+i]=source_name[i];
|
||||
ram.memory[0x501]=4;ram.memory[0x521]=1;
|
||||
for(unsigned i=0;source_text[i];i++)ram.memory[0xf002+i]=source_text[i];
|
||||
ram.memory[0xf006]=0;
|
||||
for(unsigned i=0;source_text[i];i++)memoryWrite(WIDE_FILE_BASE+2+i,source_text[i]);
|
||||
memoryWrite(WIDE_FILE_BASE+6,0);
|
||||
if(storage_path("build/cpu-snapshot.b32"))return 1;
|
||||
verify(snapshotService(0x300,0)==0,"wide snapshot save");
|
||||
ram.memory[0xf000]=0;
|
||||
verify(snapshotService(0x300,1)==0 && ram.memory[0xf000]==0x12345678,"wide snapshot restores all 32 bits");
|
||||
memoryWrite(WIDE_FILE_BASE,0);
|
||||
verify(snapshotService(0x300,1)==0 && memoryRead(WIDE_FILE_BASE)==0x12345678,"wide snapshot restores all 32 bits");
|
||||
FILE *saved=fopen("build/cpu-snapshot.b32","r+b");if(!saved)return 1;
|
||||
if(fseek(saved,16+216*4+3,SEEK_SET))return 1;
|
||||
if(fputc(0x13,saved)==EOF || fclose(saved))return 1;
|
||||
ram.memory[0xf000]=42;
|
||||
verify(snapshotService(0x300,1)==-2 && ram.memory[0xf000]==42,"wide snapshot checksum protects upper byte and RAM");
|
||||
ram.memory[0xf000]=0x12345678;
|
||||
memoryWrite(WIDE_FILE_BASE,42);
|
||||
verify(snapshotService(0x300,1)==-2 && memoryRead(WIDE_FILE_BASE)==42,"wide snapshot checksum protects upper byte and RAM");
|
||||
memoryWrite(WIDE_FILE_BASE,0x12345678);
|
||||
verify(snapshotService(0x300,0)==0,"wide snapshot resave");
|
||||
FILE *old_snapshot=fopen("build/cpu-snapshot.b32","r+b");if(!old_snapshot)return 1;
|
||||
FILE *old_snapshot=fopen("build/cpu-snapshot.b32","rb");if(!old_snapshot)return 1;
|
||||
uint32_t old_words[SNAP_WORDS];if(fseek(old_snapshot,16,SEEK_SET))return 1;
|
||||
for(unsigned i=0;i<SNAP_WORDS;i++){unsigned char b[4];if(fread(b,1,4,old_snapshot)!=4)return 1;old_words[i]=(uint32_t)b[0]|((uint32_t)b[1]<<8)|((uint32_t)b[2]<<16)|((uint32_t)b[3]<<24);}
|
||||
for(unsigned i=0;i<=4;i++)old_words[216+512+i]=old_words[218+i];
|
||||
uint32_t old_hash=snapshotHash(old_words,SNAP_WORDS);if(fseek(old_snapshot,4,SEEK_SET)||fputc(1,old_snapshot)==EOF||fseek(old_snapshot,12,SEEK_SET))return 1;
|
||||
for(unsigned i=0;i<4;i++)if(fputc((old_hash>>(8*i))&255,old_snapshot)==EOF)return 1;
|
||||
if(fseek(old_snapshot,16,SEEK_SET))return 1;
|
||||
for(unsigned i=0;i<SNAP_WORDS;i++)for(unsigned b=0;b<4;b++)if(fputc((old_words[i]>>(8*b))&255,old_snapshot)==EOF)return 1;
|
||||
if(fclose(old_snapshot))return 1;
|
||||
ram.memory[0xf000]=0;ram.memory[0xf002]=0;
|
||||
verify(snapshotService(0x300,1)==0 && ram.memory[0xf000]==0x12345678 && ram.memory[0xf002]=='b',"legacy fixed-slot B32S snapshot converts to packed filesystem layout");
|
||||
FILE *old_write=fopen("build/cpu-snapshot.b32","wb");if(!old_write)return 1;
|
||||
uint32_t old_hash=snapshotHash(old_words,SNAP_WORDS);unsigned char old_header[16]={'B','3','2','S',2,0,0,0};
|
||||
for(unsigned i=0;i<4;i++){old_header[8+i]=(unsigned char)(kernelIdentity>>(8*i));old_header[12+i]=(unsigned char)(old_hash>>(8*i));}
|
||||
if(fwrite(old_header,1,16,old_write)!=16)return 1;
|
||||
for(unsigned i=0;i<SNAP_WORDS;i++)for(unsigned b=0;b<4;b++)if(fputc((old_words[i]>>(8*b))&255,old_write)==EOF)return 1;
|
||||
if(fclose(old_write))return 1;
|
||||
memoryWrite(WIDE_FILE_BASE,0);memoryWrite(WIDE_FILE_BASE+2,0);
|
||||
verify(snapshotService(0x300,1)==0 && memoryRead(WIDE_FILE_BASE)==0x12345678 && memoryRead(WIDE_FILE_BASE+2)=='b',"B32S v2 packed snapshot restores into expanded storage");
|
||||
uint32_t fixed_native[2]={old_words[216],old_words[217]},fixed_text[5];
|
||||
for(unsigned i=0;i<5;i++)fixed_text[i]=old_words[218+i];
|
||||
memset(old_words+216,0,SNAP_OLD_FILE_WORDS*sizeof(uint32_t));
|
||||
for(unsigned i=0;i<2;i++)old_words[216+i]=fixed_native[i];
|
||||
for(unsigned i=0;i<5;i++)old_words[216+512+i]=fixed_text[i];
|
||||
old_hash=snapshotHash(old_words,SNAP_WORDS);old_header[4]=1;
|
||||
for(unsigned i=0;i<4;i++)old_header[12+i]=(unsigned char)(old_hash>>(8*i));
|
||||
old_write=fopen("build/cpu-snapshot.b32","wb");if(!old_write)return 1;
|
||||
if(fwrite(old_header,1,16,old_write)!=16)return 1;
|
||||
for(unsigned i=0;i<SNAP_WORDS;i++)for(unsigned b=0;b<4;b++)if(fputc((old_words[i]>>(8*b))&255,old_write)==EOF)return 1;
|
||||
if(fclose(old_write))return 1;
|
||||
memoryWrite(WIDE_FILE_BASE,0);memoryWrite(WIDE_FILE_BASE+2,0);
|
||||
verify(snapshotService(0x300,1)==0 && memoryRead(WIDE_FILE_BASE)==0x12345678 && memoryRead(WIDE_FILE_BASE+2)=='b',"B32S v1 fixed-slot snapshot converts into expanded packed storage");
|
||||
cpu32=false;ram.memory[0xf000]=42;
|
||||
verify(snapshotService(0x300,1)==-2 && ram.memory[0xf000]==42,"legacy rejects wide snapshot without modifying RAM");
|
||||
cpu32=true;kernelIdentity++;
|
||||
verify(snapshotService(0x300,1)==1,"wide snapshot reports changed kernel identity");
|
||||
verify(ram.memory[0x520]==0 && ram.memory[0x521]==1 && ram.memory[0xf000]=='b' && ram.memory[0xf003]=='!',"wide kernel change drops binaries and preserves text");
|
||||
verify(ram.memory[0x520]==0 && ram.memory[0x521]==1 && memoryRead(WIDE_FILE_BASE)=='b' && memoryRead(WIDE_FILE_BASE+3)=='!',"wide kernel change drops binaries and preserves text");
|
||||
kernelIdentity--;
|
||||
if(storage_path(""))return 1;
|
||||
uint32_t snapshot[SNAP_WORDS]={0};
|
||||
uint32_t snapshot[SNAP_WIDE_WORDS]={0};
|
||||
verify(snapshotValid(snapshot),"empty snapshot metadata");
|
||||
snapshot[0]='b';snapshot[1]='o';snapshot[2]='b';snapshot[3]='!';snapshot[192]=4;snapshot[208]=1;
|
||||
snapshot[216]='b';snapshot[217]='o';snapshot[218]='b';snapshot[219]='!';
|
||||
verify(snapshotValid(snapshot),"valid text snapshot metadata");
|
||||
snapshot[218]=0;verify(!snapshotValid(snapshot),"text snapshot rejects embedded terminator");snapshot[218]='b';
|
||||
snapshot[220]=1;verify(!snapshotValid(snapshot),"snapshot rejects missing content terminator");snapshot[220]=0;
|
||||
snapshot[192]=512;verify(!snapshotValid(snapshot),"snapshot rejects excessive length");snapshot[192]=4;
|
||||
snapshot[192]=SNAP_FILE_WORDS;verify(!snapshotValid(snapshot),"snapshot rejects excessive length");snapshot[192]=4;
|
||||
snapshot[208]=2;verify(!snapshotValid(snapshot),"snapshot rejects invalid used flag");snapshot[208]=1;
|
||||
snapshot[200]=2;verify(snapshotValid(snapshot),"bob32 snapshots accept native program files");
|
||||
snapshot[200]=4;verify(!snapshotValid(snapshot),"snapshot rejects invalid kind");snapshot[200]=0;
|
||||
@@ -342,15 +378,15 @@ int main(int argc,char **argv) {
|
||||
reset_cpu(1);ram.memory[0x300]=0xf000;ram.memory[0x301]=7;
|
||||
ram.memory[0xf000]=0x4233324b;ram.memory[0xf001]=0x00180002;ram.memory[0xf002]=0x20000;ram.memory[0xf003]=0x20000;
|
||||
ram.memory[0xf004]=1;ram.memory[0xf005]=0xe000;ram.memory[0xf006]=0xe000;
|
||||
verify(runWidePackedFromGuest(0x300)==0,"native app loads and executes from packed guest RAM image");
|
||||
verify(runWidePackedFromGuest(0x300,NULL)==0,"native app loads and executes from packed guest RAM image");
|
||||
reset_cpu(1);ram.memory[0x300]=0xf000;ram.memory[0x301]=7;
|
||||
ram.memory[0xf000]=0x4233324b;ram.memory[0xf001]=0x00180002;ram.memory[0xf002]=0x20000;ram.memory[0xf003]=0x20000;
|
||||
ram.memory[0xf004]=1;ram.memory[0xf005]=0xe000;ram.memory[0xf006]=0;
|
||||
verify(runWidePackedFromGuest(0x300)==-4,"native app checksum corruption rejected before execution");
|
||||
verify(runWidePackedFromGuest(0x300,NULL)==-4,"native app checksum corruption rejected before execution");
|
||||
reset_cpu(1);ram.memory[0x300]=0xf000;ram.memory[0x301]=7;
|
||||
ram.memory[0xf000]=0x4233324b;ram.memory[0xf001]=0x00180002;ram.memory[0xf002]=0x20000;ram.memory[0xf003]=0x20000;
|
||||
ram.memory[0xf004]=1;ram.memory[0xf005]=0xe000;ram.memory[0xf006]=0xe000;failNextSparsePageAllocation=1;
|
||||
verify(runWidePackedFromGuest(0x300)==-5 && memoryPage(0x10,0)==NULL,"native app reports insufficient sparse memory without partial load");
|
||||
verify(runWidePackedFromGuest(0x300,NULL)==-5 && memoryPage(0x10,0)==NULL,"native app reports insufficient sparse memory without partial load");
|
||||
f=fopen("build/cpu-import.b32","wb");if(!f)return 1;
|
||||
fwrite("B32K",1,4,f);put16(f,2);put16(f,24);put32(f,0x20000);put32(f,0x20000);put32(f,1);put32(f,0xe000);put32(f,0xe000);if(fclose(f))return 1;
|
||||
reset_cpu(1);const char *import_path="build/cpu-import.b32";
|
||||
@@ -360,7 +396,7 @@ int main(int argc,char **argv) {
|
||||
ram.memory[0x302]=8;
|
||||
verify(importWideImageFromGuest(0x300)==7 && ram.memory[0xf006]==0xe000,"native image import validates and packs a B32K v2 image");
|
||||
ram.memory[0x310]=0xf000;ram.memory[0x311]=7;
|
||||
verify(runWidePackedFromGuest(0x310)==0,"imported native image executes from packed filesystem storage");
|
||||
verify(runWidePackedFromGuest(0x310,NULL)==0,"imported native image executes from packed filesystem storage");
|
||||
bootImage("build/kernel.b16");verify(!cpu32,"legacy image selects compatibility mode");
|
||||
f=fopen("build/cpu-input.basm","w");if(!f)return 1;
|
||||
fputs("lea r0 2\ntrap 2\ntrap 0\n.stringz bob!\n",f);fclose(f);
|
||||
|
||||
+300
-7
@@ -54,9 +54,9 @@ static void guest32(const char *source) {
|
||||
write_text("build/wide-lib.c",source);
|
||||
check(system("gcc -E -P -nostdinc -undef -DBOBC_LEGACY=0 -I kernel build/wide-lib.c -o build/wide-lib.i > build/compiler.log 2>&1")==0,"bob32 library guest preprocessing");
|
||||
check(system(COMPILER " build/wide-lib.i build/wide-lib.basm build/wide-lib.b32 --wide > build/compiler.log 2>&1")==0,"bob32 library guest compilation");
|
||||
write_text("build/check.in","");
|
||||
check(system(BOB32 " --boot build/wide-lib.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"bob32 library guest execution");
|
||||
char *output=read_text("build/check.out");check(!strcmp(output,"bob!\n"),"bob32 library success marker");free(output);
|
||||
write_text("build/check.in","run32 build/wide-lib.b32\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"bob32 library guest execution under OS services");
|
||||
char *output=read_text("build/check.out");contains(output,"bob!");free(output);
|
||||
}
|
||||
static void native_string_library(void) {
|
||||
guest32(
|
||||
@@ -96,15 +96,305 @@ static void native_string_library(void) {
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"bob32 string-library app survives snapshot restore");
|
||||
output=read_text("build/check.out");contains(output,"Files restored;");contains(output,"bob> bob!\nExit 0");free(output);
|
||||
write_text("build/argv-app.c",
|
||||
"#include \"bob.h\"\n#include \"bob_string.h\"\n"
|
||||
"int main(int argc,char **argv){if(argc!=5)return argc;"
|
||||
"#include \"bob.h\"\n#include \"bob_string.h\"\n#include \"bob_fs.h\"\n"
|
||||
"int main(int argc,char **argv){char data[16];char name[24];int size;int kind;int i;int old;"
|
||||
"if(argc!=4)return argc;"
|
||||
"if(bob_strcmp(argv[0],\"argvapp\")||bob_strcmp(argv[1],\"Bob OS\")||bob_strcmp(argv[2],\"escaped token\")||bob_strcmp(argv[3],\"\"))return 2;"
|
||||
"old=bob_file_read(\"note\",data,16);if(old>=0&&(old!=4||bob_strcmp(data,\"bob!\")))return 3;"
|
||||
"if(old<0&&bob_file_write(\"note\",\"bob!\",4))return 4;"
|
||||
"if(bob_file_read(\"note\",data,16)!=4||bob_strcmp(data,\"bob!\"))return 5;"
|
||||
"if(bob_file_write(\"temp\",\"x\",1)||bob_file_delete(\"temp\"))return 6;"
|
||||
"for(i=0;i<8;i++){kind=bob_file_list(i,name,24,&size);if(kind<0)continue;"
|
||||
"if(!bob_strcmp(name,\"note\")){if(kind||size!=4)return 7;break;}}if(i==8)return 8;"
|
||||
"bob_puts(\"bob!\");return 0;}\n");
|
||||
check(system("gcc -E -P -nostdinc -undef -DBOBC_LEGACY=0 -I kernel build/argv-app.c -o build/argv-app.i > build/compiler.log 2>&1")==0,"bob32 argv app preprocessing");
|
||||
check(system(COMPILER " build/argv-app.i build/argv-app.basm build/argv-app.b32 --wide-app > build/compiler.log 2>&1")==0,"bob32 argv app compilation");
|
||||
write_text("build/check.in","import32 build/argv-app.b32 argvapp\nrun argvapp \"Bob OS\" escaped\\ token \"\"\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"bob32 passes quoted arguments to native apps");
|
||||
output=read_text("build/check.out");contains(output,"bob> bob!\nExit 0");free(output);
|
||||
write_text("build/memory-app.c",
|
||||
"#include \"bob.h\"\n#include \"bob_memory.h\"\n"
|
||||
"int main(void){int storage[8];int used=0;int *first;int *second;"
|
||||
"first=bob_arena_alloc(storage,8,&used,3);second=bob_arena_alloc(storage,8,&used,5);"
|
||||
"if(first!=storage||second!=storage+3)return 2;first[2]=42;"
|
||||
"if(first[2]!=42||bob_arena_used(&used)!=8||bob_arena_remaining(8,&used)!=0)return 3;"
|
||||
"if(bob_arena_alloc(storage,8,&used,1)||bob_arena_alloc(storage,8,&used,0)||bob_arena_alloc(storage,8,&used,-1))return 4;"
|
||||
"if(bob_arena_reset(&used)||bob_arena_used(&used)||bob_arena_remaining(8,&used)!=8)return 5;"
|
||||
"if(bob_arena_alloc(storage,8,&used,8)!=storage)return 6;bob_puts(\"bob!\");return 0;}\n");
|
||||
check(system("gcc -E -P -nostdinc -undef -DBOBC_LEGACY=0 -I kernel build/memory-app.c -o build/memory-app.i > build/compiler.log 2>&1")==0,"bob32 app arena fixture preprocessing");
|
||||
check(system(COMPILER " build/memory-app.i build/memory-app.basm build/memory-app.b32 --wide-app > build/compiler.log 2>&1")==0,"bob32 app arena fixture compilation");
|
||||
write_text("build/check.in","import32 build/memory-app.b32 memoryapp\nrun memoryapp\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"native word arena allocates, bounds-checks and resets caller-owned storage");
|
||||
output=read_text("build/check.out");contains(output,"bob> bob!\nExit 0");free(output);
|
||||
write_text("build/time-app.c",
|
||||
"#include \"bob.h\"\n#include \"bob_time.h\"\n"
|
||||
"int main(void){int words[2];if(bob_time_utc_seconds(words)!=2)return 1;"
|
||||
"if(words[0]<=0||words[1]<0||words[1]>1000)return 2;"
|
||||
"bob_puts(\"bob!\");return 0;}\n");
|
||||
check(system("gcc -E -P -nostdinc -undef -DBOBC_LEGACY=0 -I kernel build/time-app.c -o build/time-app.i > build/compiler.log 2>&1")==0,"bob32 time app preprocessing");
|
||||
check(system(COMPILER " build/time-app.i build/time-app.basm build/time-app.b32 --wide-app > build/compiler.log 2>&1")==0,"bob32 time app compilation");
|
||||
write_text("build/word-fs-app.c",
|
||||
"#include \"bob.h\"\n#include \"bob_fs.h\"\n#include \"bob_string.h\"\n"
|
||||
"int main(int argc,char **argv){int source[3]={0x12345678,-1,0};int data[3];char name[24];int size;int kind;int i;int stored;"
|
||||
"stored=bob_file_read_words(\"binary\",data,3);if(stored<0){if(argc!=2||bob_strcmp(argv[1],\"create\"))return 1;"
|
||||
"if(bob_file_write_words(\"binary\",source,3,BOB_FILE_KIND_BOB32_PROGRAM))return 1;}else if(stored!=3)return 1;"
|
||||
"if(bob_file_read_words(\"binary\",data,2)!=-2)return 2;"
|
||||
"if(bob_file_read_words(\"binary\",data,3)!=3||data[0]!=source[0]||data[1]!=-1||data[2]!=0)return 3;"
|
||||
"for(i=0;i<8;i++){kind=bob_file_list(i,name,24,&size);if(kind<0)continue;if(!bob_strcmp(name,\"binary\"))break;}"
|
||||
"if(i==8||kind!=BOB_FILE_KIND_BOB32_PROGRAM||size!=3)return 4;"
|
||||
"if(argc==1&&bob_file_delete(\"binary\"))return 5;bob_puts(\"bob!\");return 0;}\n");
|
||||
check(system("gcc -E -P -nostdinc -undef -DBOBC_LEGACY=0 -I kernel build/word-fs-app.c -o build/word-fs-app.i > build/compiler.log 2>&1")==0,"native word filesystem fixture preprocessing");
|
||||
check(system(COMPILER " build/word-fs-app.i build/word-fs-app.basm build/word-fs-app.b32 --wide-app > build/compiler.log 2>&1")==0,"native word filesystem fixture compilation");
|
||||
storage_path("build/word-fs-snapshot.b32");
|
||||
write_text("build/check.in","import32 build/word-fs-app.b32 wordfs\nrun wordfs create\nsave\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"native filesystem writes binary program words into the snapshot");
|
||||
output=read_text("build/check.out");contains(output,"bob> bob!\nExit 0");free(output);
|
||||
write_text("build/check.in","restore yes\nrun wordfs\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"binary program words survive snapshot restore and can be deleted by a native app");
|
||||
output=read_text("build/check.out");contains(output,"Files restored;");contains(output,"bob> bob!\nExit 0");free(output);
|
||||
write_text("build/check.in","import32 build/time-app.b32 timeapp\nrun timeapp\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"native app reads UTC time through the versioned OS service");
|
||||
output=read_text("build/check.out");contains(output,"bob> bob!\nExit 0");free(output);
|
||||
write_text("build/native-api-app.c",
|
||||
"#include \"bob_native.h\"\n"
|
||||
"int main(void){char text[8]=\"bob\";char loaded[8];int arena_words[4];int used=0;int clock_words[2];"
|
||||
"if(bob_strcat(text,\"!\")!=text)return 1;"
|
||||
"if(bob_arena_alloc(arena_words,4,&used,2)!=arena_words||used!=2)return 2;"
|
||||
"if(bob_file_write(\"umbrella\",text,bob_strlen(text)))return 3;"
|
||||
"if(bob_file_read(\"umbrella\",loaded,8)!=4||bob_strcmp(loaded,\"bob!\"))return 4;"
|
||||
"if(bob_time_utc_seconds(clock_words)!=2||clock_words[0]<=0)return 5;"
|
||||
"if(bob_file_delete(\"umbrella\"))return 6;bob_puts(\"bob!\");return 0;}\n");
|
||||
check(system("gcc -E -P -nostdinc -undef -DBOBC_LEGACY=0 -I kernel build/native-api-app.c -o build/native-api-app.i > build/compiler.log 2>&1")==0,"common native API umbrella preprocessing");
|
||||
check(system(COMPILER " build/native-api-app.i build/native-api-app.basm build/native-api-app.b32 --wide-app > build/compiler.log 2>&1")==0,"common native API umbrella compilation");
|
||||
write_text("build/check.in","import32 build/native-api-app.b32 nativeapi\nrun nativeapi\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"native API umbrella works end to end across common services");
|
||||
output=read_text("build/check.out");contains(output,"bob> bob!\nExit 0");free(output);
|
||||
storage_path("build/snapshot.b16");
|
||||
}
|
||||
static void native_gui_geometry(void) {
|
||||
guest32(
|
||||
"#include \"bob.h\"\n#include \"bob_gui.h\"\n#include \"bob_event_queue.h\"\n"
|
||||
"int main(void){int rect[4]={3,3,34,12};int drag[3]={0,0,0};"
|
||||
"int button[4]={5,5,10,3};int state[2]={0,0};int event[4]={0,0,7,6};"
|
||||
"int field[4]={5,5,8,3};int edit[3];char text[16]=\"bob\";char long_text[8]=\"\";int long_edit[3];"
|
||||
"int area[4]={5,5,12,5};int area_state[4];char multiline[32]=\"ab\\ncd\";"
|
||||
"int wheel_state[4];char wheel_text[32]=\"1\\n2\\n3\\n4\\n5\";"
|
||||
"int stack[8]={0,0,10,10,5,5,10,10};int order[2]={0,1};"
|
||||
"int menu[4]={10,5,20,5};int menu_state[2]={0,-1};int placed[4];"
|
||||
"int queue_state[2],queue_storage[12],queued[4],dequeued[4];"
|
||||
"int wm[10],wm_windows[21],wm_order[3],wm_routed[4],wm_a,wm_b;"
|
||||
"if(!bob_gui_window_hit(3,3,rect)||bob_gui_window_hit(37,3,rect))return 1;"
|
||||
"if(bob_gui_window_at(6,6,stack,order,2)!=1||!bob_gui_raise_window(order,2,0)||bob_gui_window_at(6,6,stack,order,2)!=0)return 19;"
|
||||
"if(order[0]!=1||order[1]!=0||bob_gui_raise_window(order,2,3)||bob_gui_window_at(20,20,stack,order,2)!=-1)return 20;"
|
||||
"if(!bob_gui_drag_start(rect,drag,8,3)||!drag[0]||drag[1]!=5)return 2;"
|
||||
"if(!bob_gui_drag_update(rect,drag,15,9,80,25)||rect[0]!=10||rect[1]!=9)return 3;"
|
||||
"bob_gui_drag_update(rect,drag,200,40,80,25);"
|
||||
"if(rect[0]!=46||rect[1]!=13)return 4;"
|
||||
"if(!bob_gui_drag_stop(drag)||bob_gui_drag_update(rect,drag,0,0,80,25))return 5;"
|
||||
"if(bob_gui_drag_start(rect,drag,47,14))return 6;"
|
||||
"event[0]=BOB_EVENT_MOUSE_MOVE;if(bob_gui_button_event(button,state,event)||!state[0])return 7;"
|
||||
"event[0]=BOB_EVENT_MOUSE_BUTTON_DOWN;event[1]=BOB_MOUSE_BUTTON_RIGHT;"
|
||||
"if(bob_gui_button_event(button,state,event)||state[1])return 8;"
|
||||
"event[1]=BOB_MOUSE_BUTTON_LEFT;if(bob_gui_button_event(button,state,event)||!state[1])return 9;"
|
||||
"event[0]=BOB_EVENT_MOUSE_BUTTON_UP;event[1]=0;"
|
||||
"if(!bob_gui_button_event(button,state,event)||state[1])return 10;"
|
||||
"event[0]=BOB_EVENT_MOUSE_BUTTON_DOWN;event[1]=BOB_MOUSE_BUTTON_LEFT;bob_gui_button_event(button,state,event);"
|
||||
"event[0]=BOB_EVENT_MOUSE_BUTTON_UP;event[1]=0;event[2]=20;"
|
||||
"if(bob_gui_button_event(button,state,event)||state[1])return 11;"
|
||||
"if(bob_gui_text_field_init(text,edit,16)!=3||edit[1]!=3)return 12;"
|
||||
"event[0]=BOB_EVENT_MOUSE_BUTTON_DOWN;event[2]=7;event[3]=6;"
|
||||
"bob_gui_text_field_event(field,text,edit,16,event);if(!edit[0]||edit[1]!=1)return 13;"
|
||||
"event[0]=BOB_EVENT_CHAR;event[1]='!';"
|
||||
"if(!bob_gui_text_field_event(field,text,edit,16,event)||text[0]!='b'||text[1]!='!'||text[2]!='o')return 14;"
|
||||
"event[0]=BOB_EVENT_KEY_DOWN;event[1]=259;bob_gui_text_field_event(field,text,edit,16,event);"
|
||||
"event[0]=BOB_EVENT_CHAR;event[1]=8;bob_gui_text_field_event(field,text,edit,16,event);"
|
||||
"if(text[0]!='b'||text[1]!='!'||text[2]!='b'||text[3])return 15;"
|
||||
"event[0]=BOB_EVENT_KEY_DOWN;event[1]=260;bob_gui_text_field_event(field,text,edit,16,event);"
|
||||
"event[1]=262;bob_gui_text_field_event(field,text,edit,16,event);if(text[0]!='!'||text[1]!='b'||text[2])return 16;"
|
||||
"event[0]=BOB_EVENT_MOUSE_BUTTON_DOWN;event[2]=20;bob_gui_text_field_event(field,text,edit,16,event);"
|
||||
"event[0]=BOB_EVENT_CHAR;event[1]='x';bob_gui_text_field_event(field,text,edit,16,event);"
|
||||
"if(edit[0]||text[0]!='!'||text[1]!='b')return 17;"
|
||||
"bob_gui_text_field_init(long_text,long_edit,8);long_edit[0]=1;"
|
||||
"for(int i=0;i<7;i++){event[0]=BOB_EVENT_CHAR;event[1]='a'+i;bob_gui_text_field_event(field,long_text,long_edit,8,event);}"
|
||||
"if(long_edit[1]!=7||long_edit[2]!=2||long_text[7])return 18;"
|
||||
"if(bob_gui_text_area_init(multiline,area_state,32)!=5||area_state[1]!=5||area_state[2]!=0)return 21;"
|
||||
"event[0]=BOB_EVENT_MOUSE_BUTTON_DOWN;event[1]=BOB_MOUSE_BUTTON_LEFT;event[2]=8;event[3]=7;"
|
||||
"bob_gui_text_area_event(area,multiline,area_state,32,event);if(!area_state[0])return 26;"
|
||||
"event[0]=BOB_EVENT_KEY_DOWN;event[1]=256;bob_gui_text_area_event(area,multiline,area_state,32,event);"
|
||||
"if(area_state[1]!=2)return 22;event[0]=BOB_EVENT_CHAR;event[1]='X';bob_gui_text_area_event(area,multiline,area_state,32,event);"
|
||||
"if(multiline[0]!='a'||multiline[1]!='b'||multiline[2]!='X'||multiline[3]!='\\n')return 23;"
|
||||
"event[0]=BOB_EVENT_KEY_DOWN;event[1]=257;bob_gui_text_area_event(area,multiline,area_state,32,event);"
|
||||
"if(area_state[1]!=6)return 24;event[0]=BOB_EVENT_CHAR;event[1]=8;bob_gui_text_area_event(area,multiline,area_state,32,event);"
|
||||
"if(multiline[4]!='c'||multiline[5])return 25;"
|
||||
"if(bob_gui_text_area_init(wheel_text,wheel_state,32)!=9)return 27;"
|
||||
"bob_gui_text_area_reveal(wheel_text,wheel_state,area);if(wheel_state[2]!=2)return 28;"
|
||||
"event[0]=BOB_EVENT_MOUSE_WHEEL;event[1]=120;event[2]=6;event[3]=6;"
|
||||
"bob_gui_text_area_event(area,wheel_text,wheel_state,32,event);if(wheel_state[2]!=1)return 29;"
|
||||
"bob_gui_text_area_event(area,wheel_text,wheel_state,32,event);if(wheel_state[2]!=0)return 30;"
|
||||
"bob_gui_text_area_event(area,wheel_text,wheel_state,32,event);if(wheel_state[2]!=0)return 31;"
|
||||
"event[1]=-120;bob_gui_text_area_event(area,wheel_text,wheel_state,32,event);"
|
||||
"bob_gui_text_area_event(area,wheel_text,wheel_state,32,event);if(wheel_state[2]!=2)return 32;"
|
||||
"bob_gui_text_area_event(area,wheel_text,wheel_state,32,event);if(wheel_state[2]!=2)return 33;"
|
||||
"bob_event_queue_init(queue_state);if(bob_event_queue_pop(queue_state,queue_storage,3,dequeued)!=0)return 42;"
|
||||
"event[0]=BOB_EVENT_KEY_DOWN;event[1]=257;event[2]=11;event[3]=12;"
|
||||
"if(bob_event_queue_push(queue_state,queue_storage,3,event)!=1)return 43;"
|
||||
"event[1]=258;if(bob_event_queue_push(queue_state,queue_storage,3,event)!=1)return 44;"
|
||||
"event[1]=259;if(bob_event_queue_push(queue_state,queue_storage,3,event)!=1)return 45;"
|
||||
"if(bob_event_queue_push(queue_state,queue_storage,3,event)!=0)return 46;"
|
||||
"if(bob_event_queue_pop(queue_state,queue_storage,3,dequeued)!=1||dequeued[1]!=257||dequeued[2]!=11)return 47;"
|
||||
"event[1]=260;if(bob_event_queue_push(queue_state,queue_storage,3,event)!=1)return 48;"
|
||||
"if(bob_event_queue_pop(queue_state,queue_storage,3,dequeued)!=1||dequeued[1]!=258)return 49;"
|
||||
"if(bob_event_queue_pop(queue_state,queue_storage,3,dequeued)!=1||dequeued[1]!=259)return 50;"
|
||||
"if(bob_event_queue_pop(queue_state,queue_storage,3,dequeued)!=1||dequeued[1]!=260)return 51;"
|
||||
"if(bob_event_queue_pop(queue_state,queue_storage,3,dequeued)!=0)return 52;"
|
||||
"if(bob_event_queue_push(queue_state,queue_storage,0,event)!=-1)return 53;"
|
||||
"if(bob_wm_init(wm,wm_windows,wm_order,3,80,25))return 54;"
|
||||
"wm_a=bob_wm_create(wm,wm_windows,wm_order,5,5,20,10);wm_b=bob_wm_create(wm,wm_windows,wm_order,10,8,20,10);"
|
||||
"if(wm_a!=0||wm_b!=1||wm[2]!=wm_b||wm_order[0]!=wm_a||wm_order[1]!=wm_b)return 55;"
|
||||
"event[0]=BOB_EVENT_KEY_DOWN;event[1]=256;if(bob_wm_dispatch(wm,wm_windows,wm_order,event,wm_routed)!=wm_b)return 56;"
|
||||
"event[0]=BOB_EVENT_MOUSE_BUTTON_DOWN;event[1]=BOB_MOUSE_BUTTON_LEFT;event[2]=12;event[3]=9;"
|
||||
"if(bob_wm_dispatch(wm,wm_windows,wm_order,event,wm_routed)!=wm_b||wm[2]!=wm_b||wm_routed[2]!=2||wm_routed[3]!=1)return 57;"
|
||||
"event[2]=6;event[3]=6;if(bob_wm_dispatch(wm,wm_windows,wm_order,event,wm_routed)!=wm_a||wm[2]!=wm_a||wm_order[1]!=wm_a)return 58;"
|
||||
"event[0]=BOB_EVENT_KEY_DOWN;event[1]=257;event[2]=0;event[3]=0;if(bob_wm_dispatch(wm,wm_windows,wm_order,event,wm_routed)!=wm_a)return 59;"
|
||||
"event[2]=6;event[3]=5;if(bob_wm_dispatch(wm,wm_windows,wm_order,event,wm_routed)!=wm_a||wm[3]!=wm_a)return 60;"
|
||||
"event[0]=BOB_EVENT_MOUSE_MOVE;event[2]=79;event[3]=24;"
|
||||
"if(bob_wm_dispatch(wm,wm_windows,wm_order,event,wm_routed)!=wm_a||wm_windows[0]!=60||wm_windows[1]!=15||wm_routed[2]!=19||wm_routed[3]!=9)return 61;"
|
||||
"event[2]=0;event[3]=0;bob_wm_dispatch(wm,wm_windows,wm_order,event,wm_routed);"
|
||||
"if(wm_windows[0]!=0||wm_windows[1]!=0)return 62;event[0]=BOB_EVENT_MOUSE_BUTTON_UP;"
|
||||
"if(bob_wm_dispatch(wm,wm_windows,wm_order,event,wm_routed)!=wm_a||wm[3]!=-1)return 63;"
|
||||
"bob_wm_begin_draw(wm,wm_windows,wm_order);if(bob_wm_next_dirty(wm,wm_windows,wm_order)!=wm_b||bob_wm_next_dirty(wm,wm_windows,wm_order)!=wm_a||bob_wm_next_dirty(wm,wm_windows,wm_order)!=-1)return 64;"
|
||||
"bob_wm_invalidate(wm,wm_windows,wm_order,wm_a);bob_wm_begin_draw(wm,wm_windows,wm_order);"
|
||||
"if(bob_wm_next_dirty(wm,wm_windows,wm_order)!=wm_b||bob_wm_next_dirty(wm,wm_windows,wm_order)!=wm_a)return 65;"
|
||||
"if(bob_wm_show(wm,wm_windows,wm_order,wm_a,0)!=1||wm[2]!=wm_b)return 66;"
|
||||
"event[0]=BOB_EVENT_KEY_DOWN;if(bob_wm_dispatch(wm,wm_windows,wm_order,event,wm_routed)!=wm_b)return 67;"
|
||||
"if(bob_wm_destroy(wm,wm_windows,wm_order,wm_b)||wm[2]!=-1||wm[1]!=1)return 68;"
|
||||
"if(bob_wm_destroy(wm,wm_windows,wm_order,wm_b)!=-1||bob_wm_create(wm,wm_windows,wm_order,0,0,81,10)!=-1)return 69;"
|
||||
"if(bob_wm_create(wm,wm_windows,wm_order,1,1,4,3)!=wm_b||bob_wm_destroy(wm,wm_windows,wm_order,wm_b))return 70;"
|
||||
"if(bob_wm_init(wm,wm_windows,wm_order,9,80,25)!=-1)return 71;"
|
||||
"if(bob_gui_menu_place(placed,76,23,20,3,80,25)||placed[0]!=60||placed[1]!=20||placed[2]!=20||placed[3]!=5)return 39;"
|
||||
"if(bob_gui_menu_place(placed,-4,-2,20,3,80,25)||placed[0]!=0||placed[1]!=0)return 40;"
|
||||
"if(bob_gui_menu_place(placed,0,0,90,3,80,25)!=-1)return 41;"
|
||||
"if(bob_gui_menu_event(menu,3,menu_state,event)!=-1||menu_state[0]!=0)return 34;"
|
||||
"event[0]=BOB_EVENT_KEY_DOWN;event[1]=257;bob_gui_menu_event(menu,3,menu_state,event);if(menu_state[0]!=1)return 35;"
|
||||
"event[0]=BOB_EVENT_CHAR;event[1]=10;if(bob_gui_menu_event(menu,3,menu_state,event)!=1)return 36;"
|
||||
"event[1]=27;if(bob_gui_menu_event(menu,3,menu_state,event)!=-2)return 37;"
|
||||
"event[0]=BOB_EVENT_MOUSE_BUTTON_DOWN;event[1]=BOB_MOUSE_BUTTON_LEFT;event[2]=12;event[3]=8;"
|
||||
"bob_gui_menu_event(menu,3,menu_state,event);event[0]=BOB_EVENT_MOUSE_BUTTON_UP;event[1]=0;"
|
||||
"if(bob_gui_menu_event(menu,3,menu_state,event)!=1)return 38;"
|
||||
"bob_puts(\"bob!\");return 0;}\n");
|
||||
}
|
||||
static void native_filesystem_apps(void) {
|
||||
write_text("build/notes-check.c","");
|
||||
check(system("gcc -E -P -nostdinc -undef -DBOBC_LEGACY=0 -I kernel apps/notes.c -o build/notes-check.i > build/compiler.log 2>&1")==0,"notes app preprocessing");
|
||||
check(system(COMPILER " build/notes-check.i build/notes-check.basm build/notes-check.b32 --wide-app > build/compiler.log 2>&1")==0,"notes app compilation");
|
||||
const char *utilities[]={"echo","ls","cat","sysinfo","graphics_demo","gui_demo","launcher"};
|
||||
for(int i=0;i<7;i++) {
|
||||
char command[512];
|
||||
snprintf(command,sizeof(command),"gcc -E -P -nostdinc -undef -DBOBC_LEGACY=0 -I kernel apps/%s.c -o build/%s-check.i > build/compiler.log 2>&1",utilities[i],utilities[i]);
|
||||
check(system(command)==0,"native utility preprocessing");
|
||||
snprintf(command,sizeof(command),COMPILER " build/%s-check.i build/%s-check.basm build/%s-check.b32 --wide-app > build/compiler.log 2>&1",utilities[i],utilities[i],utilities[i]);
|
||||
check(system(command)==0,"native utility compilation");
|
||||
}
|
||||
storage_path("build/notes-snapshot.b32");
|
||||
write_text("build/check.in","import32 build/notes-check.b32 notes\nrun notes put journal \"bob! saved note\"\nrun notes edit journal \"bob! edited note\"\nrun notes add journal \"second line\"\nrun notes show journal\nsave\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"native notes app creates and reads a text file");
|
||||
char *output=read_text("build/check.out");contains(output,"Imported native app as notes");contains(output,"Saved.");contains(output,"bob! edited note\nsecond line\nExit 0");contains(output,"Files saved to bob-files.b32");free(output);
|
||||
write_text("build/check.in","restore yes\nrun notes show journal\nrun notes delete notes\nrun notes delete journal\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"native notes and files survive snapshot restore");
|
||||
output=read_text("build/check.out");contains(output,"bob! edited note\nsecond line\nExit 0");contains(output,"Not a text note.\nExit 1");contains(output,"Deleted.\nExit 0");contains(output,"Files restored;");free(output);
|
||||
write_text("build/check.in","import32 build/echo-check.b32 echo\nrun echo bob! \"two words\"\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"native echo receives command-line arguments");
|
||||
output=read_text("build/check.out");contains(output,"bob! two words\nExit 0");free(output);
|
||||
write_text("build/check.in","run32 build/ls-check.b32\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"native ls lists guest files");
|
||||
output=read_text("build/check.out");contains(output,"bob.c 45 text");free(output);
|
||||
storage_path("build/launcher-snapshot.b32");
|
||||
write_text("build/check.in","import32 build/launcher-check.b32 launcher\nimport32 build/echo-check.b32 echo\nimport32 build/notes-check.b32 notes\nrun launcher\nrun launcher echo \"nested saved note\"\nrun launcher notes put childnote \"written by child\"\nrun notes show childnote\nsave\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"expanded filesystem holds multiple apps and launcher persists child writes");
|
||||
output=read_text("build/check.out");contains(output,"Native apps:");contains(output,"launcher");contains(output,"echo");contains(output,"notes");contains(output,"Child exit:\n0\n");contains(output,"Saved.\nChild exit:\n0\n");contains(output,"written by child\nExit 0");contains(output,"Files saved to bob-files.b32");free(output);
|
||||
FILE *wide_snapshot=fopen("build/launcher-snapshot.b32","rb");check(wide_snapshot!=NULL,"expanded B32S snapshot exists");if(wide_snapshot){unsigned char header[8];check(fread(header,1,8,wide_snapshot)==8&&!memcmp(header,"B32S\3\0\0\0",8),"expanded filesystem uses B32S v3");fseek(wide_snapshot,0,SEEK_END);check(ftell(wide_snapshot)==16+(216+8192)*4,"B32S v3 stores the full expanded payload");fclose(wide_snapshot);}
|
||||
write_text("build/check.in","restore yes\nrun launcher echo \"snapshot child\"\nrun notes show childnote\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"nested apps and child-written files survive snapshot restore");
|
||||
output=read_text("build/check.out");contains(output,"Files restored;");contains(output,"snapshot child\nChild exit:\n0\n");contains(output,"written by child\nExit 0");free(output);
|
||||
write_text("build/check.in","run32 build/sysinfo-check.b32\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"native sysinfo queries the OS service API");
|
||||
output=read_text("build/check.out");contains(output,"bob32 system information");contains(output,"System API version: 1");contains(output,"Cell framebuffer: available");contains(output,"Display width (cells): 80");contains(output,"Display height (cells): 25");contains(output,"Keyboard input: available");contains(output,"Filesystem words free: ");free(output);
|
||||
write_text("build/check.in","run32 build/graphics_demo-check.b32\nx\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"graphics demo draws, reads a key, and returns to the shell");
|
||||
output=read_text("build/check.out");contains(output,"BOB32 GRAPHICS DEMO");contains(output,"Press any key to return to the shell");contains(output,"bob!\nExit 0");free(output);
|
||||
write_text("build/gui-child.c","#include \"bob.h\"\nint main(void){bob_puts(\"GUI child reached\");return 7;}\n");
|
||||
check(system("gcc -E -P -nostdinc -undef -DBOBC_LEGACY=0 -I kernel build/gui-child.c -o build/gui-child.i > build/compiler.log 2>&1")==0,"GUI launcher child preprocessing");
|
||||
check(system(COMPILER " build/gui-child.i build/gui-child.basm build/gui-child.b32 --wide-app > build/compiler.log 2>&1")==0,"GUI launcher child compilation");
|
||||
write_text("build/check.in","import32 build/gui-child.b32 gui_child\nrun32 build/gui_demo-check.b32\n\t\tar\x1b\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"GUI launcher starts a stored native app and returns to the desktop");
|
||||
output=read_text("build/check.out");contains(output,"Application launcher");contains(output,"GUI child reached");contains(output,"App exit 7");contains(output,"bob!\nExit 0");free(output);
|
||||
write_text("build/check.in","run32 build/gui_demo-check.b32\n?\x1b\x1b\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"GUI bitmap-font help overlay opens and returns cleanly");
|
||||
output=read_text("build/check.out");contains(output,"Desktop help");contains(output,"##### #### # ####");contains(output,"bob!\nExit 0");free(output);
|
||||
write_text("build/check.in","run32 build/gui_demo-check.b32\n\t\tm\n\x1b\x1b\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"GUI popup menu opens, navigates, and edits a selected text file");
|
||||
output=read_text("build/check.out");contains(output,"File menu: M or click File");contains(output,"Open selected text");contains(output,"Delete selected");contains(output,"Editing selected file.");contains(output,"bob!\nExit 0");free(output);
|
||||
write_text("build/font-demo.c",
|
||||
"#include \"bob.h\"\n#include \"bob_font.h\"\n"
|
||||
"int main(void){if(bob_gfx_enter()||bob_gfx_clear('.',1))return 1;"
|
||||
"if(bob_gfx_bitmap_text(2,2,\"BOB!\",14)||bob_gfx_present()||bob_gfx_leave())return 2;"
|
||||
"bob_puts(\"bob!\");return 0;}\n");
|
||||
check(system("gcc -E -P -nostdinc -undef -DBOBC_LEGACY=0 -I kernel build/font-demo.c -o build/font-demo.i > build/compiler.log 2>&1")==0,"bitmap font fixture preprocessing");
|
||||
check(system(COMPILER " build/font-demo.i build/font-demo.basm build/font-demo.b32 --wide-app > build/compiler.log 2>&1")==0,"bitmap font fixture compilation");
|
||||
write_text("build/check.in","run32 build/font-demo.b32\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"native bitmap font draws text through the graphics service");
|
||||
output=read_text("build/check.out");contains(output,"####...###..####....#");contains(output,"bob!\nExit 0");free(output);
|
||||
write_text("build/event-poll.c",
|
||||
"#include \"bob.h\"\n#include \"bob_event.h\"\n"
|
||||
"int main(void){int event[4];if(bob_event_poll(event)!=0)return 1;"
|
||||
"if(bob_event_wait(event)!=1||event[0]!=BOB_EVENT_CHAR||event[1]!='k')return 2;"
|
||||
"bob_puts(\"bob!\");return 0;}\n");
|
||||
check(system("gcc -E -P -nostdinc -undef -DBOBC_LEGACY=0 -I kernel build/event-poll.c -o build/event-poll.i > build/compiler.log 2>&1")==0,"nonblocking input fixture preprocessing");
|
||||
check(system(COMPILER " build/event-poll.i build/event-poll.basm build/event-poll.b32 --wide-app > build/compiler.log 2>&1")==0,"nonblocking input fixture compilation");
|
||||
write_text("build/check.in","run32 build/event-poll.b32\nk\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"nonblocking event poll leaves redirected input for blocking wait");
|
||||
output=read_text("build/check.out");contains(output,"bob!\nExit 0");free(output);
|
||||
write_text("build/color-blit.c",
|
||||
"#include \"bob.h\"\n#include \"bob_gfx.h\"\n"
|
||||
"int main(void){int icon[4]={0x141,0x242,0,0x343};int bad[1]={0x1000};"
|
||||
"if(bob_gfx_enter()||bob_gfx_clear(' ',7))return 1;"
|
||||
"if(bob_gfx_blit_color(2,2,1,1,bad)!=-1)return 2;"
|
||||
"if(bob_gfx_blit_color(2,2,2,2,icon)||bob_gfx_present()||bob_gfx_leave())return 3;"
|
||||
"bob_puts(\"bob!\");return 0;}\n");
|
||||
check(system("gcc -E -P -nostdinc -undef -DBOBC_LEGACY=0 -I kernel build/color-blit.c -o build/color-blit.i > build/compiler.log 2>&1")==0,"colored bitmap fixture preprocessing");
|
||||
check(system(COMPILER " build/color-blit.i build/color-blit.basm build/color-blit.b32 --wide-app > build/compiler.log 2>&1")==0,"colored bitmap fixture compilation");
|
||||
write_text("build/check.in","run32 build/color-blit.b32\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"colored transparent bitmap app renders through the OS graphics service");
|
||||
output=read_text("build/check.out");contains(output,"AB");contains(output," C");contains(output,"bob!\nExit 0");free(output);
|
||||
write_text("build/gui-seed.c",
|
||||
"#include \"bob.h\"\n#include \"bob_fs.h\"\n#include \"bob_string.h\"\n"
|
||||
"int main(void){char data[256];int i;for(i=0;i<210;i++)data[i]='a';"
|
||||
"bob_strcpy(data+210,\"PREVIEW-CONTENT-42\");"
|
||||
"if(bob_file_write(\"gui.txt\",data,210+bob_strlen(data+210)))return 1;return 0;}\n");
|
||||
check(system("gcc -E -P -nostdinc -undef -DBOBC_LEGACY=0 -I kernel build/gui-seed.c -o build/gui-seed.i > build/compiler.log 2>&1")==0,"GUI long-preview fixture preprocessing");
|
||||
check(system(COMPILER " build/gui-seed.i build/gui-seed.basm build/gui-seed.b32 --wide-app > build/compiler.log 2>&1")==0,"GUI long-preview fixture compilation");
|
||||
storage_path("build/gui-files-snapshot.b32");
|
||||
write_text("build/check.in","import32 build/cat-check.b32 cat\nrun32 build/gui-seed.b32\nrun32 build/gui_demo-check.b32\n\t\tnndxnxy\x13\x1b\nrun cat gui.txt\nsave\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"GUI file editor saves a text file and returns cleanly");
|
||||
output=read_text("build/check.out");contains(output,"Text editor");contains(output,"Window B");contains(output,"bob.c");contains(output,"gui.txt");contains(output,"PREVIEW-CONTENT-42");char *first_confirmation=strstr(output,"Delete? Y/N");check(first_confirmation&&strstr(first_confirmation+1,"Delete? Y/N"),"GUI delete cancellation leaves file available for confirmation");contains(output,"Delete selected text file?");contains(output,"Yes, delete");contains(output,"Cancel");contains(output,"Deleted.");contains(output,"new.txt");contains(output,"Cannot read text file.\nExit 1");contains(output,"Files saved to bob-files.b32");contains(output,"bob!\nExit 0");free(output);
|
||||
write_text("build/check.in","restore yes\nrun cat new.txt\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"GUI-created file survives snapshot restore");
|
||||
output=read_text("build/check.out");contains(output,"Files restored;");contains(output,"bob!\nExit 0");free(output);
|
||||
write_text("build/gui-edit-seed.c","#include \"bob.h\"\n#include \"bob_fs.h\"\n#include \"bob_string.h\"\nint main(void){return bob_file_write(\"multi.txt\",\"first\\nsecond\",bob_strlen(\"first\\nsecond\"))!=0;}\n");
|
||||
check(system("gcc -E -P -nostdinc -undef -DBOBC_LEGACY=0 -I kernel build/gui-edit-seed.c -o build/gui-edit-seed.i > build/compiler.log 2>&1")==0,"GUI multiline edit fixture preprocessing");
|
||||
check(system(COMPILER " build/gui-edit-seed.i build/gui-edit-seed.basm build/gui-edit-seed.b32 --wide-app > build/compiler.log 2>&1")==0,"GUI multiline edit fixture compilation");
|
||||
write_text("build/check.in","import32 build/cat-check.b32 cat\nrun32 build/gui-edit-seed.b32\nrun32 build/gui_demo-check.b32\n\t\tnne!\x13\x1b\nrun cat multi.txt\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"GUI opens, edits, and saves a multiline text file");
|
||||
output=read_text("build/check.out");contains(output,"E opens text. Tab changes focus.");contains(output,"Editing selected file.");contains(output,"first\nsecond!\nExit 0");contains(output,"bob!\nExit 0");free(output);
|
||||
write_text("build/check.in","import32 build/cat-check.b32 cat\nwrite sample.c bob!\nrun cat sample.c\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"native cat reads guest text files");
|
||||
output=read_text("build/check.out");contains(output,"bob!\nExit 0");free(output);
|
||||
write_text("build/cat-lines.c","#include \"bob.h\"\n#include \"bob_fs.h\"\nint main(void){if(bob_file_write(\"trail\",\"line\\n\",5))return 1;if(bob_file_write(\"empty\",\"\",0))return 2;return 0;}\n");
|
||||
check(system("gcc -E -P -nostdinc -undef -DBOBC_LEGACY=0 -I kernel build/cat-lines.c -o build/cat-lines.i > build/compiler.log 2>&1")==0,"cat newline fixture preprocessing");
|
||||
check(system(COMPILER " build/cat-lines.i build/cat-lines.basm build/cat-lines.b32 --wide-app > build/compiler.log 2>&1")==0,"cat newline fixture compilation");
|
||||
write_text("build/check.in","import32 build/cat-check.b32 cat\nrun32 build/cat-lines.b32\nrun cat trail\nrun cat empty\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"native cat preserves existing newlines and handles empty files");
|
||||
output=read_text("build/check.out");contains(output,"line\nExit 0\nbob> Exit 0");free(output);
|
||||
storage_path("build/snapshot.b16");
|
||||
}
|
||||
static void wide_guest(void) {
|
||||
@@ -193,6 +483,9 @@ static void input_bounds(void) {
|
||||
char commands[400];memset(commands,'x',200);strcpy(commands+200,"\necho bob!\nhalt\n");
|
||||
char *output=shell(commands);contains(output,"Command too long.");contains(output,"bob> bob!\n");
|
||||
not_contains(output,"Unknown command");free(output);
|
||||
output=shell("echo old\necho bob!\nhistory\nhistory extra\nhalt\n");
|
||||
contains(output,"1 echo old");contains(output,"2 echo bob!");contains(output,"3 history");
|
||||
contains(output,"Usage: history");free(output);
|
||||
output=shell("");check(!strcmp(output,"bob!\nbob16 OS: help COMMAND for usage; go bob.c runs the example.\nFiles are in RAM; halt exits. Type help to get started.\nbob> \n"),"EOF exits shell");free(output);
|
||||
output=shell("echo bxo\b\bbob!\nhalt\n");contains(output,"bob> bbob!\n");free(output);
|
||||
}
|
||||
@@ -737,7 +1030,7 @@ static void storage_path(const char *path) {
|
||||
static void wide_kernel_workflow(void) {
|
||||
storage_path("build/wide-snapshot.b32");remove("build/wide-snapshot.b32");
|
||||
write_text("build/check.in","mem\nalloc 4\npoke 0xd000 77\npeek 0xd000\npoke 0xc000 88\npeek 0xc000\ngo bob.c\nedit compat.c\nint main(void) {\nint n=0x12345678;\nif(n+1!=0x12345679 || n*2!=0x2468ACF0 || n/3!=101806632 || n%3)return 1;\nprintln(\"bob!\");\nreturn 0;\n}\n.\ngo compat.c\ndelete compat.c\nedit tern.c\nint main(void) {\nint a=0;\nint b=1?2:3;\nint c=0?4:1?5:6;\nint d=1?7:a++;\nif(b==2&&c==5&&d==7&&a==0)println(\"bob!\");\nreturn 0;\n}\n.\ngo tern.c\ndelete tern.c\nedit loops.c\nint main(void) {\nint i=0;\nint calls=0;\ndo { i++; if(i==2)continue; calls++; if(i==4)break; } while(i<10);\ndo { calls++; } while(0);\nif(calls==4)println(\"bob!\");\nreturn 0;\n}\n.\ngo loops.c\ndelete loops.c\nedit assign.c\nint main(void) {\nint a=0; int b=1; int i=0;\nint x=(a=b=3);\na+=2; b<<=2; b>>=1;\nif(x==3&&a==5&&b==6&&((i=i+1)==1))println(\"bob!\");\nreturn 0;\n}\n.\ngo assign.c\ndelete assign.c\nedit funcs.c\nint main(void) {\nannounce();\nif(add(fact(5),2)==122)println(\"bob!\");\nreturn 0;\n}\nint announce(void) {\nprintln(\"bob!\");\nreturn 0;\n}\nint fact(int n) {\nif(n<2)return 1;\nreturn n*fact(n-1);\n}\nint add(int x,int y) {\nint value=x+y;\nreturn value;\n}\n.\ngo funcs.c\ndelete funcs.c\nedit scope.c\nint main(void) {\nint value=3;\n{int value=8;if(value!=8)return 1;}\n{int value=9;if(value!=9)return 2;}\nint count=99;\nfor(int count=0;count<2;count++){int inner=count;if(inner!=count)return 3;}\nif(value==3&&count==99)println(\"bob!\");\nreturn 0;\n}\n.\ngo scope.c\ndelete scope.c\nwrite hex.c int main(void){print_hex(4660);println(\"bob!\");return 0;}\ngo hex.c\nload old 0xD002 0xF200 0xF000 0x0062 0x006F 0x0062 0x0021 0x0000\nrun old\nedit note\nbob!\n.\nread note\nls\ncc bob.c app\nrun app\nsave\nhalt\n");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 50000000 < build/check.in > build/check.out 2> build/check.err")==0,"bob32 OS shell workflow");
|
||||
check(system(BOB32 " --boot build/kernel32.b32 --max-cycles 60000000 < build/check.in > build/check.out 2> build/check.err")==0,"bob32 OS shell workflow");
|
||||
char *output=read_text("build/check.out");int successful_apps=0;const char *success_cursor=output;
|
||||
while((success_cursor=strstr(success_cursor,"bob!\nExit 0"))){successful_apps++;success_cursor+=11;}
|
||||
check(successful_apps==9,"B32 resident programs all complete successfully");
|
||||
@@ -1392,6 +1685,6 @@ static void basm_route(void) {
|
||||
int main(void) {
|
||||
console_and_commands();input_bounds();allocator_and_files();resident_compiler();
|
||||
compiler_extensions();wide_guest();editor_and_aliases();
|
||||
program_loading_and_recovery();native_string_library();host_compiler_and_runtime();host_language_rejections();file_management();compile_workflow();usability();persistence();shell_editing();image_validation();basm_route();wide_kernel_workflow();wide_local_arrays();wide_array_parameters();wide_resident_large_output();wide_function_prototypes();wide_function_pointers();wide_local_offset_limit();
|
||||
program_loading_and_recovery();native_string_library();native_gui_geometry();native_filesystem_apps();host_compiler_and_runtime();host_language_rejections();file_management();compile_workflow();usability();persistence();shell_editing();image_validation();basm_route();wide_kernel_workflow();wide_local_arrays();wide_array_parameters();wide_resident_large_output();wide_function_prototypes();wide_function_pointers();wide_local_offset_limit();
|
||||
printf("bob!\n%d checks passed.\n",checks);return 0;
|
||||
}
|
||||
Reference in new issue
Block a user