Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add bhyveload mock #11

Merged
merged 3 commits into from
Feb 17, 2018
Merged

tests: add bhyveload mock #11

merged 3 commits into from
Feb 17, 2018

Conversation

fabianfreyer
Copy link
Contributor

@fabianfreyer fabianfreyer commented Feb 16, 2018

Contributes to #1

  • Mock out the following callbacks:
    • getc: not implemented
    • putc: not implemented
    • poll: not implemented
    • open: copy from bhyveload
    • close: copy from bhyveload
    • isdir: copy from bhyveload
    • read: copy from bhyveload
    • readdir: copy from bhyveload
    • seek: copy from bhyveload
    • stat: copy from bhyveload
    • diskread: not implemented
    • diskioctl: not implemented
    • copyin: mock out
    • copyout: mock out
    • setreg: mock out
    • setmsr: mock out
    • setcr: mock out
    • setgdt: mock out
    • exec: not implemented
    • delay: not implemented
    • exit: mock out
    • getmem: mock out
    • getenv: copy from bhyveload
    • vm_set_register: mock out
    • vm_set_desc: mock out
  • write tests that the mock callbacks work as expected:
    • getc
    • putc
    • poll
    • open
    • close
    • isdir
    • read
    • readdir
    • seek
    • stat
    • diskread
    • diskioctl
    • copyin
    • copyout
    • setreg
    • setmsr
    • setcr
    • setgdt
    • exec
    • delay
    • exit
    • getmem
    • getenv
    • vm_set_register
    • vm_set_desc

@fabianfreyer fabianfreyer added help wanted Extra attention is needed tests labels Feb 16, 2018
@fabianfreyer fabianfreyer added this to the v0.1 milestone Feb 16, 2018
@fabianfreyer fabianfreyer changed the title tests: add basic bhyveload mock tests: add test harness for loader Feb 16, 2018
@fabianfreyer fabianfreyer force-pushed the test-harness branch 2 times, most recently from 5bc466f to da96cf3 Compare February 16, 2018 05:20
@codecov
Copy link

codecov bot commented Feb 16, 2018

Codecov Report

Merging #11 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@         Coverage Diff          @@
##           master   #11   +/-   ##
====================================
  Coverage       0%    0%           
====================================
  Files           3     3           
  Lines         222   222           
====================================
  Misses        222   222

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b798ecd...b6fbc96. Read the comment docs.

@@ -34,6 +34,9 @@
#define MiB (size_t) (1024 * 1024)
#define GiB (size_t) (1024 * 1024 * 1024)

/* copyin into in the highmem is currently not supported by bhyveload. */
#define TEST_HIGHMEM_ALLOCATION 0
Copy link
Contributor Author

@fabianfreyer fabianfreyer Feb 16, 2018

Choose a reason for hiding this comment

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

usr.sbin/bhyveload/bhyveload.c:338:

	to &= 0x7fffffff;

Looks like highmem copyins go to lowmem, so we disable highmem allocation here.

strlcpy(path, host_base, PATH_MAX);
if (path[strlen(path) - 1] == '/')
path[strlen(path) - 1] = 0;
strlcat(path, filename, PATH_MAX);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

strlcat and strlcpy are not portable:

mock/bhyveload.c:87:2: warning: implicitly declaring library function 'strlcpy'
      with type 'unsigned long (char *, const char *, unsigned long)'
      [-Wimplicit-function-declaration]
        strlcpy(path, host_base, PATH_MAX);
        ^
mock/bhyveload.c:87:2: note: include the header <string.h> or explicitly provide
      a declaration for 'strlcpy'
mock/bhyveload.c:90:2: warning: implicitly declaring library function 'strlcat'
      with type 'unsigned long (char *, const char *, unsigned long)'
      [-Wimplicit-function-declaration]
        strlcat(path, filename, PATH_MAX);
        ^

Implement a mock object implementing most of the callbacks of
userboot.so allowing access to the emulated state. Tests for these
mock callbacks are implemented.
@fabianfreyer
Copy link
Contributor Author

fabianfreyer commented Feb 17, 2018

I'll squash the above commits when merging this issue.

@fabianfreyer fabianfreyer changed the title tests: add test harness for loader tests: add bhyveload mock Feb 17, 2018
@fabianfreyer fabianfreyer merged commit b6fbc96 into master Feb 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant