[PUP-8326] MacOS 10.13 unit test fails on APFS file system when creating invalid UTF-8 file name Created: 2018/01/05  Updated: 2018/02/05  Resolved: 2018/01/05

Status: Closed
Project: Puppet
Component/s: None
Affects Version/s: PUP 5.3.3
Fix Version/s: PUP 5.3.4

Type: Bug Priority: Normal
Reporter: Eric Delaney Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template: PUP Bug Template
Team: Platform OS
Method Found: Automated Test
Release Notes: Not Needed
QA Risk Assessment: No Action


So I upgraded my Mac to High Sierra and now I've got a new unit test that is failing. It appears that I'm on the new APFS filesystem and it doesn't allows an invalid utf-8 encoding for the filename so the test fails.

  1) Puppet::Indirector::JSON#search raises if the content contains binary
     Failure/Error: File.binwrite(subject.path("foo#{binary}.bin", ''), "foo-binary")
       Illegal byte sequence @ rb_sysopen - /var/folders/41/jfjd_k_n0tdg_m_gn_m7ykfh0000gq/T/rspecrun20180105-46754-10h4tji/jsondir20180105-46754-1s9q9vu/indirector_testing/foo??.bin
     # ./spec/unit/indirector/json_spec.rb:206:in `binwrite'
     # ./spec/unit/indirector/json_spec.rb:206:in `block (3 levels) in <top (required)>'
     # util/rspec_runner:44:in `run'
     # util/rspec_runner:59:in `<main>'
Finished in 9.71 seconds (files took 3.05 seconds to load)
Finished in 2 minutes 11.5 seconds
23427 examples, 1 failure, 43 pending
Failed examples:
rspec ./spec/unit/indirector/json_spec.rb:202 # Puppet::Indirector::JSON#search raises if the content contains binary

Here you can see that its really the binwrite that is throwing EILSEQ

14:11 $ ruby --version
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin17]
✔ ~/work/my_repos/puppet [5.3.x ↓·6|✚ 1…1⚑ 1]
14:11 $ irb
irb(main):001:0> binary = "\xC0\xFF".force_encoding(Encoding::BINARY)
=> "\xC0\xFF"
irb(main):002:0> File.binwrite("/tmp/foo#{binary}.bin", "foo-binary")
Errno::EILSEQ: Illegal byte sequence @ rb_sysopen - /tmp/foo��.bin
	from (irb):2:in `binwrite'
	from (irb):2
	from /Users/eric.delaney/.rbenv/versions/2.4.2/bin/irb:11:in `<main>'
irb(main):003:0> binary.encoding
=> #<Encoding:ASCII-8BIT>
irb(main):004:0> string = "/tmp/foo#{binary}.bin"
=> "/tmp/foo\xC0\xFF.bin"
irb(main):005:0> File.binwrite(string, "bin")
Errno::EILSEQ: Illegal byte sequence @ rb_sysopen - /tmp/foo��.bin
	from (irb):5:in `binwrite'
	from (irb):5
	from /Users/eric.delaney/.rbenv/versions/2.4.2/bin/irb:11:in `<main>'

My mac is running on the new APFS filesystem:

✔ ~/work/my_repos/puppet [5.3.x ↓·6|✚ 1…1⚑ 1]
14:18 $ mount
/dev/disk1s1 on / (apfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
/dev/disk1s4 on /private/var/vm (apfs, local, noexec, journaled, noatime, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
✔ ~/work/my_repos/puppet [5.3.x ↓·6|✚ 1…1⚑ 1]

Comment by Eric Delaney [ 2018/01/05 ]

We decided to remove the test as its not really testing anything useful.


Generated at Sun Jan 17 17:44:06 PST 2021 using Jira 8.5.2#805002-sha1:a66f9354b9e12ac788984e5d84669c903a370049.