Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions build/unix/unittest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ include ../rules.mak
vpath %.c ../../../unittest

LDLIBS += -L../libtoolshed -L../libcoco -L../libcecb -L../libdecb \
-L../librbf -L../libmisc -L../libnative -L../libsys \
-ltoolshed -lcoco -lcecb -ldecb -lrbf -lmisc -lnative -lsys -lm
-L../librbf -L../libnative -L../libmisc -L../libsys \
-ltoolshed -lcoco -lcecb -ldecb -lrbf -lnative -lmisc -lsys -lm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Is this necessary to fix the regression, or just better for some reason?
Did it fail to compile without this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It failed on GitHub's build farm because of the misordering of these two libraries.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@strickyak click the red X, you can see build log. Its line 8 that matters, as previously _native_open wasn't being used but now that it is, depends on libmisc.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Craig @callsop . I used the similar tools at Google very effectively for years, but Github still feels a bit alien to me. I'm learning!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to merge this with my checked-in PR,
QSY to #34


TESTS = librbftest libdecbtest libcecbtest libtoolshedtest
TESTS = librbftest libdecbtest libcecbtest libtoolshedtest os9commandtest

testall: $(TESTS)
ifeq (,$(NOTEST))
./librbftest
./libdecbtest
./libcecbtest
./libtoolshedtest
./os9commandtest
endif

clean:
Expand Down
18 changes: 10 additions & 8 deletions os9/os9format.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static char const *const helpMessage[] = {
" -szX = sectors for track 0 (default = 18)\n",
" -dr = format a Dragon disk\n",
" Hard Drive Options:\n",
" -lX = number of logical sectors\n",
" -lX = number of logical sectors (floppy options ignored)\n",
NULL
};

Expand All @@ -51,7 +51,7 @@ int os9format(int argc, char **argv)
int tracks = 35;
int heads = 1;
int sectorsPerTrack = DEF_SECTORS_TRACK;
int sectorsTrack0 = DEF_SECTORS_TRACK;
int sectorsTrack0 = 0; /* mark as unset */
int bytesPerSector = 256;
int tpi = 48; /* 48 tpi */
int density = 1; /* double density */
Expand Down Expand Up @@ -185,11 +185,6 @@ int os9format(int argc, char **argv)

case 't':
sectorsPerTrack = atoi(p + 2);
// Change sectors on track 0 only if it's not already been changed.
if (DEF_SECTORS_TRACK == sectorsTrack0)
{
sectorsTrack0 = sectorsPerTrack;
}
break;

case 'z':
Expand Down Expand Up @@ -245,6 +240,12 @@ int os9format(int argc, char **argv)
}
}

/* match sectors on track 0 only if it's unset. */
if (sectorsTrack0 == 0)
{
sectorsTrack0 = sectorsPerTrack;
}

/* if logicalSectors != 0, then format as a hard drive image */
if (logicalSectors != 0)
{
Expand All @@ -270,6 +271,7 @@ int os9format(int argc, char **argv)
if (logicalSectors % i == 0)
{
sectorsPerTrack = logicalSectors / i;
sectorsTrack0 = sectorsPerTrack;
heads = i;
i = 0;
}
Expand All @@ -289,7 +291,7 @@ int os9format(int argc, char **argv)

error_code ec =
_os9_format(argv[i], os968k, tracks,
sectorsPerTrack,sectorsTrack0,
sectorsPerTrack, sectorsTrack0,
heads, bytesPerSector, &clusterSize,
diskName, sectorAllocationSize,
tpi, density, formatEntire,
Expand Down
43 changes: 43 additions & 0 deletions unittest/os9commandtest.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* ALWAYS BE TESTING!!!
*
* ALWAYS BE WRITING MORE TESTS!!!
*
* THIS WORK IS **NEVER** DONE!!!
*/

#include "tinytest.h"
#include <toolshed.h>

void test_os9_command_format()
{
error_code ec;
native_path_id nativepath;
u_int size;

ec = system("../os9/os9 format -e test.dsk -l65000 > /dev/null 2>&1");
ASSERT_EQUALS(0, ec);

ec = _native_open(&nativepath, "test.dsk", FAM_READ);
ASSERT_EQUALS(0, ec);

ec = _native_gs_size(nativepath, &size);
ASSERT_EQUALS(0, ec);
ASSERT_EQUALS(65000*256, size);

ec = _native_close(nativepath);
ASSERT_EQUALS(0, ec);

ec = _os9_makdir("test.dsk,/CMDS");
ASSERT_EQUALS(0, ec);
}

int main()
{
remove("test.dsk");
RUN(test_os9_command_format);

remove("test.dsk");

return TEST_REPORT();
}