Make the tests work. Actually export the build artifacts after building.

This commit is contained in:
David Given 2022-06-02 21:58:05 +02:00
parent db40778dce
commit 23c5892ef6
17 changed files with 272 additions and 77 deletions

10
BUILD
View file

@ -2,4 +2,14 @@ package(default_visibility = ["//visibility:public"])
exports_files([ "diskdefs" ])
filegroup(
name = "diskimages",
srcs = [
"//arch/brotherop2:diskimage",
"//arch/brotherwp1:diskimage",
"//arch/kayproii:diskimage",
"//arch/nc200:diskimage",
"//arch/wp2450ds:diskimage",
]
)

View file

@ -1,6 +1,9 @@
all:
bazel build -c opt //...
bazel test -c dbg //...
bazel build -c opt //:diskimages
for a in $$(dirname bazel-bin/arch/*/diskimage.img); do f=$$(basename $$a); ln -sf bazel-bin/arch/$$f/diskimage.img $$f.img; done
verbose:
bazel build -s -c opt //...
bazel test -s -c dbg //...
bazel build -s -c opt //:diskimages

View file

@ -1,3 +1,5 @@
package(default_visibility = ["//visibility:public"])
load("//build:cpm.bzl", "cpm_addresses", "binslice", "diskimage")
load("//third_party/zmac:build.bzl", "zmac")
load("//third_party/ld80:build.bzl", "ld80")

View file

@ -0,0 +1,20 @@
load("//build:cpm.bzl", "z80test")
TESTS = [
"deblocker_calculate_buffer_address",
"deblocker_calculate_physical",
"deblocker_capacity",
"deblocker_change_block",
]
[
z80test(
name = test,
srcs = [
test + ".z80",
"//arch/common/utils:deblocker.lib",
]
)
for test in TESTS
]

View file

@ -3,13 +3,20 @@
; See COPYING.cpmish in the distribution root directory for more information.
jp main
include "../deblocker.z80"
DBS_BLOCK_SHIFT = 9
DBS_WANT_DB_CAP = 0
DPB_SPT = 0
DPB_BSH = 2
DPB_DSM = 5
include "deblocker.lib"
main:
if 1
ld ix, 0x1234
ld a, 3
ld (offset), a
call calculate_buffer_address
ld (dbs_i_offset), a
call dbs_i_calculate_buffer_address
ld bc, 0x1234 + DBS_BUFFER + (3*128)
or a

View file

@ -6,14 +6,20 @@ PHYSICAL_SECTORS = 10
PHYSICAL_TRACKS = 5
jp main
include "../deblocker.z80"
DBS_BLOCK_SHIFT = 9
DBS_WANT_DB_CAP = 0
DPB_SPT = 0
DPB_BSH = 2
DPB_DSM = 5
include "deblocker.lib"
main:
; Successful bounds check
if 1
ld ix, disk_dat
ld bc, 0
ld de, 0
call calculate_physical
call dbs_i_calculate_physical
jp z, fail
endif
@ -23,7 +29,7 @@ main:
ld ix, disk_dat
ld bc, 256 * 4 ; high byte of physical count set
ld de, 0
call calculate_physical
call dbs_i_calculate_physical
jp nz, fail ; must fail
endif
@ -31,7 +37,7 @@ main:
ld ix, disk_dat
ld bc, 255 * 4 ; high byte of physical count not set
ld de, 0
call calculate_physical
call dbs_i_calculate_physical
jp nz, fail ; must fail
endif
@ -41,7 +47,7 @@ main:
ld ix, disk_dat
ld bc, PHYSICAL_SECTORS*4
ld de, 0
call calculate_physical
call dbs_i_calculate_physical
jp nz, fail ; must fail
endif
@ -51,7 +57,7 @@ main:
ld ix, disk_dat
ld bc, 0
ld de, 256 ; high byte of count set
call calculate_physical
call dbs_i_calculate_physical
jp nz, fail ; must fail
endif
@ -59,7 +65,7 @@ main:
ld ix, disk_dat
ld bc, 0
ld de, 255 ; high byte of count not set
call calculate_physical
call dbs_i_calculate_physical
jp nz, fail ; must fail
endif
@ -69,7 +75,7 @@ main:
ld ix, disk_dat
ld bc, 0
ld de, PHYSICAL_TRACKS
call calculate_physical
call dbs_i_calculate_physical
jp nz, fail ; must fail
endif
@ -79,8 +85,8 @@ main:
ld ix, disk_dat
ld bc, 3 ; = physical sector 0
ld de, 0
call calculate_physical
ld a, (changed)
call dbs_i_calculate_physical
ld a, (dbs_i_changed)
or a
jp nz, fail
ret
@ -91,8 +97,8 @@ main:
ld ix, disk_dat
ld bc, 4 ; = physical sector 1
ld de, 0
call calculate_physical
ld a, (changed)
call dbs_i_calculate_physical
ld a, (dbs_i_changed)
cp 1
jp nz, fail
ret
@ -101,8 +107,8 @@ main:
ld ix, disk_dat
ld bc, 256*4 ; = physical sector 256
ld de, 0
call calculate_physical
ld a, (changed)
call dbs_i_calculate_physical
ld a, (dbs_i_changed)
cp 1
jp nz, fail
ret
@ -113,8 +119,8 @@ main:
ld ix, disk_dat
ld bc, 0
ld de, 0
call calculate_physical
ld a, (changed)
call dbs_i_calculate_physical
ld a, (dbs_i_changed)
or a
jp nz, fail
ret
@ -125,8 +131,8 @@ main:
ld ix, disk_dat
ld bc, 0
ld de, 1
call calculate_physical
ld a, (changed)
call dbs_i_calculate_physical
ld a, (dbs_i_changed)
cp 1
jp nz, fail
ret
@ -135,8 +141,8 @@ main:
ld ix, disk_dat
ld bc, 0
ld de, 256
call calculate_physical
ld a, (changed)
call dbs_i_calculate_physical
ld a, (dbs_i_changed)
cp 1
jp nz, fail
ret

View file

@ -27,7 +27,13 @@ cp16 macro VAR, VAL
endm
jp main
include "../deblocker.z80"
DBS_BLOCK_SHIFT = 9
DBS_WANT_DB_CAP = 1
DPB_SPT = 0
DPB_BSH = 2
DPB_DSM = 5
include "deblocker.lib"
main:
; 1kB blocks

View file

@ -17,7 +17,13 @@ cp16 macro VAR, VAL
endm
jp main
include "../deblocker.z80"
DBS_BLOCK_SHIFT = 9
DBS_WANT_DB_CAP = 0
DPB_SPT = 0
DPB_BSH = 2
DPB_DSM = 5
include "deblocker.lib"
main:
; Change to currently loaded sector.
@ -25,7 +31,7 @@ main:
call reset
ld bc, 0
ld de, 0
call change_block
call dbs_i_change_block
jp z, fail
cp8 r512_count, 0
@ -43,7 +49,7 @@ main:
ld (dirty), a
ld bc, 0
ld de, 0
call change_block
call dbs_i_change_block
jp z, fail
cp8 r512_count, 0
@ -58,10 +64,10 @@ main:
if 1
call reset
ld a, 1
ld (changed), a
ld (dbs_i_changed), a
ld bc, 1
ld de, 0
call change_block
call dbs_i_change_block
jp z, fail
cp8 r512_count, 1
@ -76,11 +82,11 @@ main:
if 1
call reset
ld a, 1
ld (changed), a
ld (dbs_i_changed), a
ld (dirty), a
ld bc, 1
ld de, 0
call change_block
call dbs_i_change_block
jp z, fail
cp8 r512_count, 1
@ -101,8 +107,8 @@ reset:
ld (r512_count), a
ld (w512_count), a
ld (dirty), a
ld (changed), a
ld (mode), a
ld (dbs_i_changed), a
ld (dbs_i_mode), a
ret
; Mock R512 which always succeeds.

View file

@ -83,5 +83,40 @@ ld80(
}
)
# Repackages the memory image as a boot track.
genrule(
name = "bootfile",
srcs = [ ":memory_img" ],
outs = [ "bootfile.img" ],
cmd = " && ".join([
"dd if=$< of=$@ status=none bs=256 count=36",
"dd if=$< of=$@ status=none bs=256 seek=36 skip=231 count=25"
])
)
unix2cpm(
name = "readme",
src = "README.md"
)
diskimage(
name = "diskimage",
format = "nc200cpm",
bootfile = ":bootfile",
map = {
"-readme.txt": ":readme",
"dump.com": "//cpmtools:dump",
"stat.com": "//cpmtools:stat",
"asm.com": "//cpmtools:asm",
"copy.com": "//cpmtools:copy",
"submit.com": "//cpmtools:submit",
"bbcbasic.com": "//third_party/bbcbasic:bbcbasic_ADM3A",
"camel80.com": "//third_party/camelforth",
"qe.com": "//cpmtools:qe_NC200",
"z8e.com": "//third_party/z8e:z8e_NC200",
"ted.com": "//third_party/ted:ted_NC200",
},
)

View file

@ -0,0 +1,4 @@
package(default_visibility = ["//visibility:public"])
exports_files([ "cpmtest.sh" ])

View file

@ -1,3 +1,69 @@
load("//third_party/zmac:build.bzl", "zmac")
load("//third_party/ld80:build.bzl", "ld80")
def z80test(name, srcs, deps=[]):
zmac(
name = name + "_zmac",
srcs = srcs
)
ld80(
name = name + "_cim",
address = 0x0100,
objs = {
0x0100: [ ":" + name + "_zmac" ] + deps
}
)
native.sh_test(
name = name + "_test",
size = "small",
srcs = [ "//build:cpmtest.sh" ],
data = [
"//utils/emu",
":" + name + "_cim"
],
args = [ "$(location //utils/emu)", "$(location :" + name + "_cim)" ],
)
#definerule("z80test",
# {
# srcs = { type="targets" },
# deps = { type="targets", default={} },
# },
# function (e)
# local rel = zmac {
# name = e.name.."_zmac",
# srcs = e.srcs,
# deps = e.deps,
# }
#
# local cim = ld80 {
# name = e.name.."_cim",
# srcs = { "-P0x0100", rel }
# }
#
# local com = bintocom {
# name = e.name.."_com",
# srcs = { cim }
# }
#
# normalrule {
# name = e.name.."_test",
# ins = {
# "utils/emu+emu",
# com
# },
# outleaves = { "log" },
# commands = {
# "%{ins[1]} %{ins[2]} > %{outs} && test ! -s %{outs}"
# }
# }
# end
#)
def cpm_addresses(name, top_of_memory=0x10000, bios_size=None):
bdos_size = 3584 # fixed
ccp_size = 2048 # fixed

6
build/cpmtest.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/sh
set -e
LOG=$(mktemp)
$1 $2 | tee $LOG
test ! -s $LOG

View file

@ -1,40 +0,0 @@
include "third_party/ld80/build.lua"
include "third_party/zmac/build.lua"
definerule("z80test",
{
srcs = { type="targets" },
deps = { type="targets", default={} },
},
function (e)
local rel = zmac {
name = e.name.."_zmac",
srcs = e.srcs,
deps = e.deps,
}
local cim = ld80 {
name = e.name.."_cim",
srcs = { "-P0x0100", rel }
}
local com = bintocom {
name = e.name.."_com",
srcs = { cim }
}
normalrule {
name = e.name.."_test",
ins = {
"utils/emu+emu",
com
},
outleaves = { "log" },
commands = {
"%{ins[1]} %{ins[2]} > %{outs} && test ! -s %{outs}"
}
}
end
)

0
third_party/libz80ex/BUILD vendored Normal file
View file

View file

@ -4,7 +4,7 @@ def unix2cpm(name, src):
srcs = [ src ],
outs = [ name + ".txt" ],
tools = [ "//utils:unix2cpm" ],
cmd = "$(location //utils:unix2cpm) $< > $@"
cmd = "$(location //utils:unix2cpm) < $< > $@"
)
def objectify(name, src):
@ -13,7 +13,16 @@ def objectify(name, src):
srcs = [ src ],
outs = [ name + ".inc" ],
tools = [ "//utils:objectify" ],
cmd = "$(location //utils:objectify) $< > $@"
cmd = "$(location //utils:objectify) < $< > $@"
)
def objectifyc(name, src):
native.genrule(
name = name,
srcs = [ src ],
outs = [ name + ".h" ],
tools = [ "//utils:objectifyc" ],
cmd = "$(location //utils:objectifyc) < $< > $@"
)
# vim: ts=4 sw=4 et

53
utils/emu/BUILD Normal file
View file

@ -0,0 +1,53 @@
load("//third_party/zmac:build.bzl", "zmac")
load("//third_party/ld80:build.bzl", "ld80")
load("//utils:build.bzl", "objectifyc")
package(default_visibility = ["//visibility:public"])
zmac(
name = "biosbdos_rel",
srcs = [
"biosbdos.z80"
],
relocatable = True
)
ld80(
name = "biosbdos_cim",
address = 0xf700,
objs = {
0xf700: [ "//third_party/zcpr1" ],
0xff00: [ ":biosbdos_rel" ]
}
)
objectifyc(
name = "biosbdos_cim_h",
src = ":biosbdos_cim"
)
cc_library(
name = "biosbdos_cim_lib",
hdrs = [ ":biosbdos_cim_h" ],
strip_include_prefix = ".",
)
cc_binary(
name = "emu",
copts = [
"-I/usr/include/z80ex",
"-Wno-unused-result",
],
linkopts = [
"-lz80ex",
"-lz80ex_dasm",
"-lreadline",
],
srcs = glob(["*.c"]) + [
"globals.h",
],
deps = [
":biosbdos_cim_lib"
]
)

View file

@ -106,3 +106,5 @@ write:
or a
ret
nop