Skip to content

Add tests for basic functionality#9

Merged
mkopec merged 3 commits intomasterfrom
claude/issue-7-20260320-1831
Mar 20, 2026
Merged

Add tests for basic functionality#9
mkopec merged 3 commits intomasterfrom
claude/issue-7-20260320-1831

Conversation

@mkopec
Copy link
Copy Markdown
Owner

@mkopec mkopec commented Mar 20, 2026

Add tests for curve interpolation, object lifecycle, zone management, and config loading.

Closes #7

Generated with Claude Code

@mkopec
Copy link
Copy Markdown
Owner Author

mkopec commented Mar 20, 2026

@claude rebase and resolve conflicts in Makefile

@claude
Copy link
Copy Markdown

claude Bot commented Mar 20, 2026

Claude finished @mkopec's task in 5m 14s —— View job


Rebasing and Resolving Makefile Conflicts

  • Gather context
  • Analyze differences between branch and master
  • Add hwmon.c and hwmon.h (missing from branch)
  • Update sensor.c and fan.c to use hwmon_resolve_path
  • Update fand.conf with new stable hwmon path format
  • Update Makefile to include hwmon.c in both targets
  • Commit and push changes

Since git rebase wasn't available in this environment, I resolved the conflicts by manually integrating the changes from master (PR #8) into this branch:

  • hwmon.c / hwmon.h — added from master (were missing from this branch)
  • sensor.c / fan.c — updated to use hwmon_resolve_path() instead of strdup()
  • fand.conf — updated to use stable device paths (e.g. .../asus-ec-sensors/hwmon) matching master's format
  • Makefile — conflict resolved: hwmon.c added to both the main and test compilation targets

Committed as fe33eb2 and pushed to the branch.

@mkopec
Copy link
Copy Markdown
Owner Author

mkopec commented Mar 20, 2026

pls resolve the test failures @claude

@claude
Copy link
Copy Markdown

claude Bot commented Mar 20, 2026

Claude finished @mkopec's task in 1m 19s —— View job


Resolving Test Failures

  • Gather context
  • Check CI status and identify failing tests
  • Analyze root cause
  • Fix Makefile
  • Commit and push

Root cause: -lyaml was placed in CFLAGS, causing it to appear before source files in the link command (gcc -lyaml ... source.c). GCC's linker resolves library symbols left-to-right — symbols from -lyaml are looked up before the referencing object files are processed, resulting in "undefined reference to yaml_*" errors.

Fix (commit 6306a8b): Moved -lyaml to a new LDFLAGS variable so it appears after the source files:

CFLAGS=-Wall -Wpedantic -g
LDFLAGS=-lyaml

@mkopec
Copy link
Copy Markdown
Owner Author

mkopec commented Mar 20, 2026

makefile still has conflicts with the master branch @claude

@claude
Copy link
Copy Markdown

claude Bot commented Mar 20, 2026

Claude finished @mkopec's task in 7m 51s —— View job


Makefile Conflict Analysis

  • Gather context - check current Makefile vs master
  • Investigate merge conflict
  • Assess resolution options

Status: CI passes ✓ — the branch's Makefile content is correct and builds successfully.

Root cause of the conflict:

Both master (PR #8) and this branch independently changed the same line in the Makefile from the common ancestor (bde50d8):

Makefile main target
Common ancestor $(CC) $(CFLAGS) fan.c sensor.c ... -o main
master $(CC) $(CFLAGS) hwmon.c fan.c ... -o main ← added hwmon.c
this branch $(CC) $(CFLAGS) hwmon.c fan.c ... -o main $(LDFLAGS) ← added hwmon.c + $(LDFLAGS)

When GitHub does a 3-way merge, this results in a conflict on the main target line.

What I cannot do: git merge and git rebase are blocked in this environment and require explicit user approval via settings.

How to resolve it — choose one option:

Option A (easiest): Click "Update branch" on this PR page (GitHub will merge master into the branch for you) — then manually resolve the Makefile conflict keeping the branch's version.

Option B (locally):

git checkout claude/issue-7-20260320-1831
git fetch origin
git merge origin/master
# Resolve Makefile conflict — keep branch version (with LDFLAGS and test target)
git add Makefile
git commit
git push

Option C: Add git merge to allowed tools in the Claude Code action config so I can run it automatically next time.

The correct final Makefile (already in the branch) is:

CC=gcc
CFLAGS=-Wall -Wpedantic -g
LDFLAGS=-lyaml

main:
	$(CC) $(CFLAGS) hwmon.c fan.c sensor.c zone.c curve.c daemon.c config.c -o main $(LDFLAGS)

test:
	$(CC) $(CFLAGS) hwmon.c fan.c sensor.c zone.c curve.c config.c test.c -o test_runner $(LDFLAGS)
	./test_runner

.PHONY: test

github-actions Bot and others added 3 commits March 20, 2026 20:06
- Rewrite test.c with tests for curve, sensor, fan, zone, and config
- Add Makefile `test` target that builds and runs test_runner
- Tests cover: curve interpolation (min/max/exact/between points),
  object create/destroy lifecycle, zone attachment limits,
  and config loading from YAML (valid, missing file, empty zones,
  multiple zones)

Co-authored-by: Michał Kopeć <mkopec@users.noreply.github.com>
Library flags must come after object files for GCC's linker to
resolve symbols correctly.

Co-authored-by: Michał Kopeć <mkopec@users.noreply.github.com>
@mkopec mkopec force-pushed the claude/issue-7-20260320-1831 branch from 6306a8b to d164b5b Compare March 20, 2026 19:06
@mkopec mkopec merged commit 3686d98 into master Mar 20, 2026
2 checks passed
@mkopec mkopec deleted the claude/issue-7-20260320-1831 branch March 20, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tests

1 participant